easy_init
also accepts hashes as parameters, which enable extended configuration, for example log files and the layout. %-5p
will print the log level, left-aligned to five characters.
#!/usr/bin/perl
use strict; use warnings;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init({
level => $INFO,
layout => '%d %-5p %m%n'
});
TRACE "bar";
DEBUG "baz";
INFO "qux";
WARN "quux";
ERROR "corge";
FATAL "grault";
Output will now be
2013/06/02 13:08:56 INFO qux
2013/06/02 13:08:56 WARN quux
2013/06/02 13:08:56 ERROR corge
2013/06/02 13:08:56 FATAL grault
For further placeholders, have a look at Log4perl's PatternLayout documentation.