]> granicus.if.org Git - ejabberd/commitdiff
New option support: log_rotate_count
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Mon, 18 Nov 2013 13:22:48 +0000 (23:22 +1000)
committerChristophe Romain <christophe.romain@process-one.net>
Wed, 2 Jul 2014 12:59:05 +0000 (14:59 +0200)
doc/guide.tex
src/ejabberd_logger.erl

index 7a469de3b30e880b5e15b40b543471addbdb9292..5240079650309d18c7562bf3ef55294f0215ac4f 100644 (file)
@@ -6069,6 +6069,15 @@ The ejabberdctl command \term{reopen-log}
 reopens the log files,
 and also renames the old ones if you didn't rename them.
 
+The option \term{log\_rotate\_count} defines the number of rotated files to keep
+by \term{reopen-log} command.
+Every such file has a numeric suffix. The exact format is:
+\begin{description}
+  \titem{log\_rotate\_count: N} The default value is 1,
+  which means only \term{ejabberd.log.0}, \term{error.log.0}
+  and \term{crash.log.0} will be kept.
+\end{description}
+
 \makesection{debugconsole}{Debug Console}
 
 The Debug Console is an Erlang shell attached to an already running \ejabberd{} server.
index 7c47b8b7271387befc4805e2231a8f95099ef998..f5ee863a8be74bb0f9316b1f6cda1e8b45d52af9 100644 (file)
@@ -83,20 +83,24 @@ start() ->
     ErrorLog = filename:join([Dir, "error.log"]),
     CrashLog = filename:join([Dir, "crash.log"]),
     LogRotateSize = get_pos_integer_env(log_rotate_size, 10*1024*1024),
+    LogRotateCount = get_pos_integer_env(log_rotate_count, 1),
     LogRateLimit = get_pos_integer_env(log_rate_limit, 100),
     application:set_env(lager, error_logger_hwm, LogRateLimit),
     application:set_env(
       lager, handlers,
       [{lager_console_backend, info},
        {lager_file_backend, [{file, ConsoleLog}, {level, info},
-                             {count, 1}, {size, LogRotateSize}]},
+                             {count, LogRotateCount}, {size, LogRotateSize}]},
        {lager_file_backend, [{file, ErrorLog}, {level, error},
-                             {count, 1}, {size, LogRotateSize}]}]),
+                             {count, LogRotateCount}, {size, LogRotateSize}]}]),
     application:set_env(lager, crash_log, CrashLog),
+    application:set_env(lager, crash_log_size, LogRotateSize),
+    application:set_env(lager, crash_log_count, LogRotateCount),
     ejabberd:start_app(lager),
     ok.
 
 reopen_log() ->
+    lager_crash_log ! rotate,
     lists:foreach(
       fun({lager_file_backend, File}) ->
               whereis(lager_event) ! {rotate, File};