I need to collect significant-event messages to a separate log file. (The regular log is rather bloated, and meant for maintenance, while the user is only interested in very few events.)
The events are not level related, although all ERROR level and up events are considered "significant". Many such events are of INFO or WARN levels. Therefore, level thresholds or matching don't seem to be the answer.
Also, events are not limited to a given branch of the hierarchy. These can emanate from all over the application, so "categories" don't seem to fit either, or do they?
Edit: Currently, I have an INFO level general, maintenance logger and a WARN level screen logger
Is there a way to achieve such a logger with Log::Log4perl?
Regards
Meir
You can achieve this by adding an additional category in your Log4perl.
You can grab an additional logger like this:
The category can have its own configuration:
ImportantApp
is the name that's used for the Appender instance, and it is configured in the two bottom lines. The first line basically means:Important
is the name of the logger, or the Category, that we grabbed above with theget_logger("Important")
.You may use a filters:
Or you can write own filter packages inherited from
Log::Log4perl::Filter
: