2017 Ericsson AB. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. logger_disk_log_h A logger_disk_log_h.xml
logger_disk_log_h A disk_log based handler for the Logger.

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 start up of the Kernel application. See an example of this below.

The handler has an overload protection mechanism that will keep the handler process and the Kernel application alive during a high load of log requests. How this feature works, and how to modify the configuration, is described in the User's Guide .

To add a new instance of the disk_log handler, use logger:add_handler/3 . The handler configuration argument is a map which may contain general configuration parameters, as documented in the User's Guide , as well as handler specific parameters.

The settings for the disk_log log file should be specified with the key disk_log_opts. These settings are a subset of the disk_log data type dlog_option().

Parameters in the disk_log_opts map:

file This is the full name of the disk_log log file. type This is the disk_log type, wrap or halt. The default value is wrap. max_no_files This is the maximum number of files that disk_log will use for its circular logging. The default value is 10. (The setting has no effect on a halt log). max_no_bytes This is the maximum number of bytes that will be written to a log file before disk_log proceeds with the next file in order (or generates an error in case of a full halt log). The default value for a wrap log is 1048576 bytes, and infinity for a halt log.

Specific configuration for the handler (represented as a sub map) is specified with the key config. It may contain the following parameter:

filesync_repeat_interval

This value (in milliseconds) specifies how often the handler will do a disk_log sync operation in order to make sure that buffered data gets written to disk. The handler will repeatedly attempt this operation, but only perform it if something has actually been logged since the last sync. The default value is 5000 milliseconds. If no_repeat is set as value, the repeated sync operation is disabled. The user can also call the sync/1 function to perform a disk_log sync.

There are a number of other configuration parameters available, that are 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 .

Note that when changing the configuration of the handler in runtime, by calling logger:set_handler_config/2 or logger:set_handler_config/3, the disk_log_opts settings may not be modified.

Example of adding a disk_log handler:

logger:add_handler(my_disk_log_h, logger_disk_log_h, #{level => error, filter_default => log, disk_log_opts => #{file => "./my_disk_log", type => wrap, max_no_files => 4, max_no_bytes => 10000}, config => #{filesync_repeat_interval => 1000}}).

In order to use the disk_log handler instead of the default standard handler when starting an Erlang node, change the Kernel default logger to use disk_log. Example:

erl -kernel logger '[{handler,default,logger_disk_log_h, #{disk_log_opts => #{file => "./system_disk_log"}}}]'
Writes buffered data to disk.

Write buffered data to disk.

See Also

logger(3), logger_std_h(3), disk_log(3)