My goal is, to log "debug"-messages (and subsequent levels: info,warning, fatal,...) to a file but only "warnings"/fatal/error to the screen. Both at the same time.
I tried with easy_init ("stealth logging"):
Log::Log4perl->easy_init(
{ level => $DEBUG, file => ":utf8> ./log_" . basename($0) . "_.log" },
{ level => $WARN, file => 'STDOUT' },
);
... BUT the level
of the second definition overwrites general loglevel.
if (false){
WARN "some bad thing"; # print this to the screen AND to the file
}else{
do_something;
DEBUG "doing something"; # print this just to the file
if (bla){WARN "another bad thing"}
}
In this case the warning goes to the screen and the file correctly, BUT the "DEBUG" message will not get printed (perl 5.26)
Putting the { level => $DEBUG ...
-line after the {level => $WARN ...
-line, then all warn- and debug-messages are printed on the screen and to the file.
Can someone please guide me, how to do this (if even possible)? Do I need to clarify?