logger_disk_log_h(3)
okay bestie, this is the logger_disk_log_h(3) page β Erlang Module Definition, section 3, and it's literally all about a disk_log based handler for Logger. no cap, I'm gonna walk you through every single detail so you can flex on your friends π
β¨
π NAME π
logger_disk_log_h β a disk_log based handler for Logger π
π DESCRIPTION π
This is a handler for Logger that offers circular (wrapped) logs by using disk_log. Multiple instances of this handler can be added to Logger, and each instance prints to its own disk log file, created with the name and settings specified in the handler configuration. π¦
The default standard handler, logger_std_h, can be replaced by a disk_log handler at startup of the Kernel application. See an example of this below. π
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 User's Guide. (iykyk, the User's Guide is that girl π)
To add a new instance of the disk_log handler, use logger:add_handler/3. The handler configuration argument is a map which can contain general configuration parameters, as documented in the User's Guide, and handler specific parameters. The specific data is stored in a sub map with the key config, and can contain the following parameters:
fileβ This is the full name of the disk log file. The option corresponds to thenameproperty in thedlog_option()datatype. The value is set when the handler is added, and it cannot be changed in runtime. Defaults to the same name as the handler identity, in the current directory. πΎtypeβ This is the disk log type,wraporhalt. The option corresponds to thetypeproperty in thedlog_option()datatype. The value is set when the handler is added, and it cannot be changed in runtime. Defaults towrap. β¨max_no_filesβ This is the maximum number of files thatdisk_loguses for its circular logging. The option corresponds to theMaxNoFileselement in thesizeproperty in thedlog_option()datatype. The value is set when the handler is added, and it cannot be changed in runtime. Defaults to10. The setting has no effect on ahaltlog. π«max_no_bytesβ This is the maximum number of bytes that is written to a log file beforedisk_logproceeds with the next file in order, or generates an error in case of a fullhaltlog. The option corresponds to theMaxNoByteselement in thesizeproperty in thedlog_option()datatype. The value is set when the handler is added, and it cannot be changed in runtime. Defaults to1048576bytes for awraplog, andinfinityfor ahaltlog. πfilesync_repeat_intervalβ This value, in milliseconds, specifies how often the handler does adisk_logsync 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. Defaults to5000milliseconds. Ifno_repeatis set as value, the repeated sync operation is disabled. The user can also call thefilesync/1function to perform adisk_logsync. β°
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 User's Guide. π«Ά
Notice that when changing the configuration of the handler in runtime, the disk_log options (file, type, max_no_files, max_no_bytes) must not be modified. β οΈ seriously, do not touch these at runtime, bestie.
Example of adding a disk_log handler:
logger:add_handler(my_disk_log_h, logger_disk_log_h,
#{config => #{file => "./my_disk_log",
type => wrap,
max_no_files => 4,
max_no_bytes => 10000,
filesync_repeat_interval => 1000}}).
To use the disk_log handler instead of the default standard handler when starting an Erlang node, change the Kernel default logger to use logger_disk_log_h. Example:
erl -kernel logger '[{handler,default,logger_disk_log_h,
#{config => #{file => "./system_disk_log"}}}]'
π See Also π
loggerlogger_std_hdisk_log
π₯ FUNCTIONS π₯
filesync(Name) -> ok | {error, Reason}
filesync(Name) -> ok | {error, Reason}
when
Name :: atom(),
Reason :: handler_busy | {badarg, term()}.
Write buffered data to disk. πΎ
that's the whole manual page, bestie! brought to you by Ericsson AB, kernel 11.0.3 β stay iconic and keep slaying πβ¨π
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms