Log4Perl - how to set exit code if any WARN, ERROR, or FATAL messages?
Posted
by pdxrlk
on Stack Overflow
See other posts from Stack Overflow
or by pdxrlk
Published on 2010-04-06T14:26:26Z
Indexed on
2010/04/06
17:33 UTC
Read the original article
Hit count: 165
Hi - I've been using Log4Perl extensively in a number of scripts. I'd like to augment those scripts to set an error code if any WARN or ERROR messages have been logged. I couldn't find any obvious way to do this based on existing documentation.
I'd like to avoid a brute-force rewrite of my existing scripts to add a check on every WARN or ERROR log message; I'd prefer to handle it prior to script exit if possible like this pseudocode:
if $log->has_warnings_or_errors then
exit 1
else
exit 0
Is there any easy way to call Log4Perl to determine if the current logger has issues messages of certain levels?
Thanks.
© Stack Overflow or respective owner