In Erlang/OTP 21.0, a new API for logging was added. The
old
See
The Erlang error logger is an event manager (see
Error logger is no longer started by default, but is
automatically started when an event handler is added
with
User-defined event handlers can be added to handle application-specific events.
Existing event handlers provided by STDLIB and SASL are still available, but are no longer used by OTP.
Warning events were introduced in Erlang/OTP R9C and are enabled
by default as from Erlang/OTP 18.0. To retain backwards compatibility
with existing user-defined event handlers, the warning events can be
tagged as
Adds a new event handler to the error logger. The event
handler must be implemented as a
The event handler must be able to handle the events in this module, see
section
The first time this function is called,
Deletes an event handler from the error logger by calling
If no more event handlers exist after the deletion,
Log a standard error event. The
Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
The event is handled by the default Logger handler.
These functions are kept for backwards compatibility and
must not be used by new code. Use the
Example:
1> error_logger:error_msg("An error occurred in ~p", [a_module]). =ERROR REPORT==== 22-May-2018::11:18:43.376917 === An error occurred in a_module ok
If the Unicode translation modifier (
Log a standard error event. Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
The event is handled by the default Logger handler.
This functions is kept for backwards compatibility and
must not be used by new code. Use the
Example:
2> error_logger:error_report([{tag1,data1},a_term,{tag2,data}]). =ERROR REPORT==== 22-May-2018::11:24:23.699306 === tag1: data1 a_term tag2: data ok 3> error_logger:error_report("Serious error in my module"). =ERROR REPORT==== 22-May-2018::11:24:45.972445 === Serious error in my module ok
Log a user-defined error event. Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
Error logger also adds a
It is recommended that
This functions is kept for backwards compatibility and
must not be used by new code. Use the
Returns
The
Log a standard information event. The
Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
The event is handled by the default Logger handler.
These functions are kept for backwards compatibility and
must not be used by new code. Use the
Example:
1> error_logger:info_msg("Something happened in ~p", [a_module]). =INFO REPORT==== 22-May-2018::12:03:32.612462 === Something happened in a_module ok
If the Unicode translation modifier (
Log a standard information event. Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
The event is handled by the default Logger handler.
This functions is kept for backwards compatibility and
must not be used by new code. Use the
Example:
2> error_logger:info_report([{tag1,data1},a_term,{tag2,data}]). =INFO REPORT==== 22-May-2018::12:06:35.994440 === tag1: data1 a_term tag2: data ok 3> error_logger:info_report("Something strange happened"). =INFO REPORT==== 22-May-2018::12:06:49.066872 === Something strange happened ok
Log a user-defined information event. Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
Error logger also adds a
It is recommended that
This functions is kept for backwards compatibility and
must not be used by new code. Use the
Enables or disables printout of standard events to a file.
This is done by adding or deleting
the
Notice that this function does not manipulate the Logger configuration directly, meaning that if the default Logger handler is already logging to a file, this function can potentially cause logging to a second file.
This function is useful as a shortcut during development
and testing, but must not be used in a production
system. See
section
Opens log file
Closes the current log file. Returns
Returns the name of the log file
Enables (
This is done by manipulating the Logger configuration. The
function is useful as a shortcut during development and
testing, but must not be used in a production system. See
section
Returns the current mapping for warning events. Events sent
using
Example:
os$ erl Erlang (BEAM) emulator version 5.4.8 [hipe] [threads:0] [kernel-poll] Eshell V5.4.8 (abort with ^G) 1> error_logger:warning_map(). warning 2> error_logger:warning_msg("Warnings tagged as: ~p~n", [warning]). =WARNING REPORT==== 11-Aug-2005::15:31:55 === Warnings tagged as: warning ok 3> User switch command --> q os$ erl +W e Erlang (BEAM) emulator version 5.4.8 [hipe] [threads:0] [kernel-poll] Eshell V5.4.8 (abort with ^G) 1> error_logger:warning_map(). error 2> error_logger:warning_msg("Warnings tagged as: ~p~n", [error]). =ERROR REPORT==== 11-Aug-2005::15:31:23 === Warnings tagged as: error ok
Log a standard warning event. The
Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
The event is handled by the default Logger handler. The log
level can be changed to error or info, see
These functions are kept for backwards compatibility and
must not be used by new code. Use the
If the Unicode translation modifier (
Log a standard warning event. Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
The event is handled by the default Logger handler. The log
level can be changed to error or info, see
This functions is kept for backwards compatibility and
must not be used by new code. Use the
Log a user-defined warning event. Error logger forwards the event to Logger, including metadata that allows backwards compatibility with legacy error logger event handlers.
Error logger also adds a
The log level can be changed to error or info, see
It is recommended that
This functions is kept for backwards compatibility and
must not be used by new code. Use the
All event handlers added to the error logger must handle
the following events.
Generated when
Generated when
Generated when
Generated when
Generated when
Generated when
Generated when
Generated when
Generated when
Notice that some system-internal events can also be
received. Therefore a catch-all clause last in the definition of
the event handler callback function