@@ -210,17 +210,26 @@ defmodule Logger do
210
210
metadata: [:error_code, :file]
211
211
212
212
Or to configure default handler, for instance, to log into a file with
213
- built-in support for log rotation:
213
+ built-in support for log rotation and compression :
214
214
215
215
config :logger, :default_handler,
216
216
config: [
217
217
file: ~c"system.log",
218
218
filesync_repeat_interval: 5000,
219
219
file_check: 5000,
220
220
max_no_bytes: 10_000_000,
221
- max_no_files: 5
221
+ max_no_files: 5,
222
+ compress_on_rotate: true
222
223
]
223
224
225
+ See [`:logger_std_h`](`:logger_std_h`) for all relevant configuration,
226
+ including overload protection. Or set `:default_handler` to false to
227
+ disable the default logging altogether:
228
+
229
+ config :logger, :default_handler, false
230
+
231
+ How to add new handlers is covered in later sections.
232
+
224
233
> #### Keywords or maps {: .tip}
225
234
>
226
235
> While Erlang's logger expects `:config` to be a map, Elixir's Logger
@@ -231,14 +240,6 @@ defmodule Logger do
231
240
> When reading the handler configuration using Erlang's APIs,
232
241
> the configuration will always be read (and written) as a map.
233
242
234
- See [`:logger_std_h`](`:logger_std_h`) for all relevant configuration,
235
- including overload protection. Or set `:default_handler` to false to
236
- disable the default logging altogether:
237
-
238
- config :logger, :default_handler, false
239
-
240
- How to add new handlers is covered in later sections.
241
-
242
243
### Compile configuration
243
244
244
245
The following configuration must be set via config files (such as
@@ -329,16 +330,19 @@ defmodule Logger do
329
330
default handler, but you can use Erlang's [`:logger`](`:logger`) module
330
331
to add other handlers too.
331
332
332
- Erlang/OTP handlers must be listed under your own application. For example,
333
- to setup an additional handler that writes to disk:
333
+ Erlang/OTP handlers must be listed under your own application.
334
+ For example, to setup an additional handler, so you write to
335
+ console and file:
334
336
335
337
config :my_app, :logger, [
336
- {:handler, :disk_log , :logger_disk_log_h , %{
338
+ {:handler, :file_log , :logger_std_h , %{
337
339
config: %{
338
- file: ' system.log' ,
340
+ file: ~c" system.log" ,
339
341
filesync_repeat_interval: 5000,
342
+ file_check: 5000,
340
343
max_no_bytes: 10_000_000,
341
- max_no_files: 5
344
+ max_no_files: 5,
345
+ compress_on_rotate: true
342
346
},
343
347
formatter: Logger.Formatter.new()
344
348
}}
@@ -355,9 +359,12 @@ defmodule Logger do
355
359
flexibility but they should avoid performing any long running action in
356
360
such handlers, as it may slow down the action being executed considerably.
357
361
At the moment, there is no built-in overload protection for Erlang handlers,
358
- so it is your responsibility to implement it. Alternatively, you can use the
359
- [`:logger_backends`](https://github.com/elixir-lang/logger_backends)
360
- project.
362
+ so it is your responsibility to implement it.
363
+
364
+ Alternatively, you can use the
365
+ [`:logger_backends`](https://github.com/elixir-lang/logger_backends) project.
366
+ It sets up a log handler with overload protection and allows incoming events
367
+ to be dispatched to multiple backends.
361
368
362
369
## Backends and backwards compatibility
363
370
0 commit comments