Implements the formatting of LoggerEvent objects with a pattern.
The LoggerLayoutPattern
lets the user specify the output format according to conversion patterns similar to the sprintf()() function.
The following table explains the characters used in LoggerPattern and all other characters that you can use in your custom pattern:
Conversion character | Meaning |
%c | Used to output the category of the logging event, i.e. logger name |
%C | Used to output the class name of the caller issuing the logging request, i.e. logger class name |
%d | Used to output the date of the logging event using format_date(). Option may specify date format, e.g. "%d{DD.MM.YYYY HH:mm:SS}" |
%E | Used to output the environment variable with name given by option, e.g. "%E{HOME}" |
%F | Used to output the file name where the logging request was issued |
%h | Used to output the hostname where the logging event was generated |
%l | Used to output location information of the caller which generated the logging event, i.e. "file:line [function()]" |
%L | Used to output the line number from where the logging request was issued, option may specify sprintf()() format, e.g. "%.3d" |
%m | Used to output the application supplied message associated with the logging event |
%M | Used to output the method name where the logging request was issued |
%n | Outputs the platform dependent line separator character or characters |
%p | Used to output the priority of the logging event |
%P | Used to output the PID where the logging event was generated |
%r | Used to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event, option may specify sprintf()() format, e.g. "%.3d" |
%t | Used to output the thread id that generated the logging event, option may specify sprintf()() format, e.g. "%.3d" |
%u | Used to output logging event unique id, option may specify sprintf()() format, e.g. "%.3d" |
%x | Used to output exception string using Util::get_exception_string() |
%% | The literal percent sign. "%%" will print a "%" sign |
For example, the LoggerLayoutPattern
with the conversion pattern "%r [%t] %-5p %c - %m%n"
will output something like:
176 [23] INFO MyLogger - New record created