Skip to content

Commit 8f24d45

Browse files
committed
Improve Logger docs, closes #13749
1 parent 960a568 commit 8f24d45

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

lib/logger/lib/logger.ex

+28-7
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,30 @@ defmodule Logger do
226226
compress_on_rotate: true
227227
]
228228
229-
See [`:logger_std_h`](`:logger_std_h`) for all relevant configuration,
230-
including overload protection. Or set `:default_handler` to false to
231-
disable the default logging altogether:
229+
You can find a complete reference on all handler options
230+
[on Erlang/OTP docs](`t::logger_handler.config/0`). Here is Elixir's
231+
default configuration for the default handler:
232+
233+
[
234+
# Do not log messages from other nodes
235+
filters: [{&:logger_filters.remote_gl/2, :stop}],
236+
filter_default: :log,
237+
formatter: &Logger.default_formatter/0,
238+
level: :all,
239+
module: :logger_std_h
240+
]
241+
242+
The `:config` customizes a specific handler module. The default handler
243+
is [`:logger_std_h`](`:logger_std_h`), which logs to standard IO, and you
244+
call find all relevant configuration in its module documentation, including
245+
information overload protection.
246+
247+
You may also set `:default_handler` to false to disable the default logging
248+
altogether:
232249
233250
config :logger, :default_handler, false
234251
235-
How to add new handlers is covered in later sections.
252+
How to add more handlers besides the default one is covered in later sections.
236253
237254
> #### Keywords or maps {: .tip}
238255
>
@@ -395,8 +412,12 @@ defmodule Logger do
395412
end
396413
end
397414
398-
Then, when you start your application, such as in the
399-
`c:Application.start/2` callback:
415+
It may return `:log` (to log the message), `:stop` (to not log the
416+
message), or `:ignore` (to ignore the filter).
417+
418+
Then you can attach the filter, either as a primary filter (which
419+
applies to all handlers), or to a specific handler, when you start
420+
your application, such as in the `c:Application.start/2` callback:
400421
401422
:logger.add_primary_filter(:word_filter, {&LogFilter.filter/2, []})
402423
@@ -405,7 +426,7 @@ defmodule Logger do
405426
Prior to Elixir v1.15, custom logging could be achieved with Logger
406427
backends. The main API for writing Logger backends have been moved to
407428
the [`:logger_backends`](https://github.com/elixir-lang/logger_backends)
408-
project. However, the backends API are still part of Elixir for backwards
429+
project. However, the backends API is still part of Elixir for backwards
409430
compatibility.
410431
411432
Important remarks:

0 commit comments

Comments
 (0)