Format Log Events as Text
Format Log Events as Text
Details
Format a LogEvent as human readable text using format.LogEvent(), which
provides a quick and easy way to customize log messages. If you need
more control and flexibility, consider using LayoutGlue instead.
see Fields
see Fields
see Fields
see Fields
Convert Layout to a character string
Read a log file written using LayoutFormat
Format Tokens
This is the same list of format tokens as for format.LogEvent()
%tThe timestamp of the message, formatted according to
timestamp_fmt)%lthe log level, lowercase
characterrepresentation%Lthe log level, uppercase
characterrepresentation%kthe log level, first letter of lowercase
characterrepresentation%Kthe log level, first letter of uppercase
characterrepresentation%nthe log level,
integerrepresentation%gthe name of the logger
%pthe PID (process ID). Useful when logging code that uses multiple threads.
%cthe calling function
%mthe log message
%rthe raw log message (without string interpolation)
%fall custom fields of
xin a pseudo-JSON like format that is optimized for human readability and console output%jall custom fields of
xin proper JSON. This requires that you have jsonlite installed and does not support colors as opposed to%f
See also
Other Layouts:
Layout,
LayoutGlue,
LayoutJson
Super class
lgr::Layout -> LayoutFormat
Active bindings
fmta
characterscalar containing format tokens. Seeformat.LogEvent().timestamp_fmta
characterscalar. Seebase::format.POSIXct().colorsa named
listof functions (like the ones provided by the package crayon) passed on onformat.LogEvent().pad_levels"right","left"orNULL. Seeformat.LogEvent().
Methods
Inherited methods
Method new()
Usage
LayoutFormat$new(
fmt = "%L [%t] %m %j",
timestamp_fmt = "%Y-%m-%d %H:%M:%OS3",
colors = NULL,
pad_levels = "right",
excluded_fields = NULL
)