.TH logger_std_h 3erl "kernel 6.2" "Ericsson AB" "Erlang Module Definition" .SH NAME logger_std_h \- Standard handler for Logger. .SH DESCRIPTION .LP This is the standard handler for Logger\&. Multiple instances of this handler can be added to Logger, and each instance prints logs to \fIstandard_io\fR\&, \fIstandard_error\fR\&, or to file\&. .LP The handler has an overload protection mechanism that keeps the handler process and the Kernel application alive during high loads of log events\&. How overload protection works, and how to configure it, is described in the \fB\fIUser\&'s Guide\fR\&\fR\&\&. .LP To add a new instance of the standard handler, use \fB\fIlogger:add_handler/3\fR\&\fR\&\&. The handler configuration argument is a map which can contain general configuration parameters, as documented in the \fB\fIUser\&'s Guide\fR\&\fR\&, and handler specific parameters\&. The specific data is stored in a sub map with the key \fIconfig\fR\&, and can contain the following parameters: .RS 2 .TP 2 .B \fItype\fR\&: This has the value \fIstandard_io\fR\&, \fIstandard_error\fR\&, \fI{file,LogFileName}\fR\&, or \fI{file,LogFileName,LogFileOpts}\fR\&\&. .RS 2 .LP If \fILogFileOpts\fR\& is specified, it replaces the default list of options used when opening the log file\&. The default list is \fI[raw,append,delayed_write]\fR\&\&. One reason to do so can be to change \fIappend\fR\& to, for example, \fIwrite\fR\&, ensuring that the old log is truncated when a node is restarted\&. See the reference manual for \fB\fIfile:open/2\fR\&\fR\& for more information about file options\&. .RE .RS 2 .LP Log files are always UTF-8 encoded\&. The encoding can not be changed by setting the option \fI{encoding,Encoding}\fR\& in \fILogFileOpts\fR\&\&. .RE .RS 2 .LP Notice that the standard handler does not have support for circular logging\&. Use the disk_log handler, \fB\fIlogger_disk_log_h\fR\&\fR\&, for this\&. .RE .RS 2 .LP The value is set when the handler is added, and it can not be changed in runtime\&. .RE .RS 2 .LP Defaults to \fIstandard_io\fR\&\&. .RE .TP 2 .B \fIfilesync_repeat_interval\fR\&: This value, in milliseconds, specifies how often the handler does a file sync operation to write buffered data to disk\&. The handler attempts the operation repeatedly, but only performs a new sync if something has actually been logged\&. .RS 2 .LP If \fIno_repeat\fR\& is set as value, the repeated file sync operation is disabled, and it is the operating system settings that determine how quickly or slowly data is written to disk\&. The user can also call the \fB\fIfilesync/1\fR\&\fR\& function to perform a file sync\&. .RE .RS 2 .LP Defaults to \fI5000\fR\& milliseconds\&. .RE .RE .LP Other configuration parameters exist, to be used for customizing the overload protection behaviour\&. The same parameters are used both in the standard handler and the disk_log handler, and are documented in the \fB\fIUser\&'s Guide\fR\&\fR\&\&. .LP Notice that if changing the configuration of the handler in runtime, the \fItype\fR\& parameter must not be modified\&. .LP Example of adding a standard handler: .LP .nf logger:add_handler(my_standard_h, logger_std_h, #{config => #{type => {file,"./system_info.log"}, filesync_repeat_interval => 1000}}). .fi .LP To set the default handler, that starts initially with the Kernel application, to log to file instead of \fIstandard_io\fR\&, change the Kernel default logger configuration\&. Example: .LP .nf erl -kernel logger '[{handler,default,logger_std_h, #{config => #{type => {file,"./log.log"}}}}]' .fi .LP An example of how to replace the standard handler with a disk_log handler at startup is found in the \fB\fIlogger_disk_log_h\fR\&\fR\& manual\&. .SH EXPORTS .LP .nf .B filesync(Name) -> ok | {error, Reason} .br .fi .br .RS .LP Types: .RS 3 Name = atom() .br Reason = handler_busy | {badarg, term()} .br .RE .RE .RS .LP Write buffered data to disk\&. .RE .SH "SEE ALSO" .LP \fB\fIlogger(3erl)\fR\&\fR\&, \fB\fIlogger_disk_log_h(3erl)\fR\&\fR\&