From 56cacefda4f18c8fdc45839b6bec1d07d0d2d78e Mon Sep 17 00:00:00 2001
From: Siri Hansen
-erl -kernel logger '[{handler,default,logger_std_h,#{config=>#{type=>{file,"/tmp/erlang.log"}}}}]'
+erl -kernel logger '[{handler,default,logger_std_h,#{config=>#{file=>"/tmp/erlang.log"}}}]'
For more information about: diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 5ed7397135..bfd0acf634 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -801,7 +801,7 @@ logger:debug(#{got => connection_request, id => Id, state => State}, [{kernel, [{logger, [{handler, default, logger_std_h, % {handler, HandlerId, Module, - #{config => #{type => {file,"log/erlang.log"}}}} % Config} + #{config => #{file => "log/erlang.log"}}} % Config} ]}]}].
Modify the default handler to print each log event as a @@ -831,10 +831,10 @@ logger:debug(#{got => connection_request, id => Id, state => State}, [{logger, [{handler, default, logger_std_h, #{level => error, - config => #{type => {file, "log/erlang.log"}}}}, + config => #{file => "log/erlang.log"}}}, {handler, info, logger_std_h, #{level => debug, - config => #{type => {file, "log/debug.log"}}}} + config => #{file => "log/debug.log"}}} ]}]}]. @@ -1004,10 +1004,10 @@ ok
Then, add a new handler which prints to file. You can use the
handler
module
-4> Config = #{config => #{type => {file,"./info.log"}}, level => info}. -#{config => #{type => {file,"./info.log"}},level => info} +4> Config = #{config => #{file => "./info.log"}, level => info}. +#{config => #{file => "./info.log"},level => info} 5> logger:add_handler(myhandler, logger_std_h, Config). ok
Since
A configuration example:
logger:add_handler(my_standard_h, logger_std_h,
- #{config => #{type => {file,"./system_info.log"},
+ #{config => #{file => "./system_info.log",
sync_mode_qlen => 100,
drop_mode_qlen => 1000,
flush_qlen => 2000}}).
diff --git a/lib/kernel/doc/src/logger_std_h.xml b/lib/kernel/doc/src/logger_std_h.xml
index 8c5a476d86..ce54a91342 100644
--- a/lib/kernel/doc/src/logger_std_h.xml
+++ b/lib/kernel/doc/src/logger_std_h.xml
@@ -55,37 +55,86 @@
is stored in a sub map with the key config , and can contain the
following parameters:
- type
+ type = standard_io | standard_error | file
-
-
This has the value standard_io , standard_error ,
- {file,LogFileName} , or {file,LogFileName,LogFileOpts} .
- LogFileOpts specify the file options used when
- opening the log file,
+
Specifies the log destination.
+ The value is set when the handler is added, and it can not
+ be changed in runtime.
+ Defaults to standard_io , unless
+ parameter file is
+ given, in which case it defaults to file .
+
+ file = file:filename()
+ -
+
This specifies the name of the log file when the handler is
+ of type file .
+ The value is set when the handler is added, and it can not
+ be changed in runtime.
+ Defaults to the same name as the handler identity, in the
+ current directory.
+
+ modes = [ file:mode() ]
+ -
+
This specifies the file modes to use when opening the log
+ file,
see file:open/2 .
- If LogFileOpts is not specified, the default option
- list used is [raw,append,delayed_write] . If LogFileOpts
- is specified, it replaces the default options list with the
+ If modes are not specified, the default list used
+ is [raw,append,delayed_write] . If modes are
+ specified, the list replaces the default modes list with the
following adjustments:
-
- If
raw is not found in the list, it is added
+ If raw is not found in the list, it is added.
-
- It
write , append or exclusice are not
- found in the list, append is added
+ If none of write , append or exclusive is
+ found in the list, append is added.
+ - If none of
delayed_write
+ or {delayed_write,Size,Delay} is found in the
+ list, delayed_write is added.
Log files are always UTF-8 encoded. The encoding can not be
- changed by setting the option {encoding,Encoding}
- in LogFileOpts .
- Notice that the standard handler does not have support for
- circular logging. Use the disk_log handler,
- logger_disk_log_h ,
- for this.
+ changed by setting the mode {encoding,Encoding} .
The value is set when the handler is added, and it can not
be changed in runtime.
- Defaults to standard_io .
+ Defaults to [raw,append,delayed_write] .
+
This parameter specifies if the log file should be rotated
+ or not. The value
Defaults to
This parameter specifies the number of rotated log file
+ archives to keep. This has meaning only
+ if
The log archives are
+ named
Notice that setting this value to
Defaults to
This parameter specifies if the rotated log file archives
+ shall be compressed or not. If set to
Defaults to
This value, in milliseconds, specifies how often the handler does
a file sync operation to write buffered data to disk. The handler attempts
@@ -104,12 +153,13 @@
standard handler and the disk_log handler, and are documented in the
Notice that if changing the configuration of the handler in runtime,
- the
Notice that if changing the configuration of the handler in
+ runtime, the
Example of adding a standard handler:
logger:add_handler(my_standard_h, logger_std_h,
- #{config => #{type => {file,"./system_info.log"},
+ #{config => #{file => "./system_info.log",
filesync_repeat_interval => 1000}}).
To set the default handler, that starts initially with @@ -117,7 +167,7 @@ logger:add_handler(my_standard_h, logger_std_h, change the Kernel default logger configuration. Example:
erl -kernel logger '[{handler,default,logger_std_h,
- #{config => #{type => {file,"./log.log"}}}}]'
+ #{config => #{file => "./log.log"}}}]'
An example of how to replace the standard handler with a disk_log handler at startup is found in the -- cgit v1.2.3