Conversion Patterns on Log4perl

Posted by robbiebow on 12 August, 2009 under perl | Be the First to Comment

As reference, here’s the markup you an use in the ConversionPattern part of your Log4perl config:

%c Category of the logging event.
%C Fully qualified package (or class) name of the caller
%d Current date in yyyy/MM/dd hh:mm:ss format
%F File where the logging event occurred
%H Hostname (if Sys::Hostname is available)
%l Fully qualified name of the calling method followed by the
callers source the file name and line number between parentheses.
%L Line number within the file where the log statement was issued
%m The message to be logged
%m{chomp} The message to be logged, stripped off a trailing newline
%M Method or function where the logging request was issued
%n Newline (OS-independent)
%p Priority of the logging event
%P pid of the current process
%r Number of milliseconds elapsed from program start to logging event
%T A stack trace of functions called

There is more, more complex, markup you can use. See the Patten Layout documentation on CPAN for more details.

Add A Comment