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 may use a filters:
log4perl.logger = WARN, Log1, Log2
log4perl.filter.Filter1 = sub { ... }
log4perl.filter.Filter2 = sub { ... }
log4perl.appender.Log1 = Log::Log4perl::Appender::Screen
log4perl.appender.Log1.Filter = Filter1
log4perl.appender.Log2 = Log::Log4perl::Appender::File
log4perl.appender.Log2.Filter = Filter2
Or you can write own filter packages inherited from Log::Log4perl::Filter
:
log4perl.logger = WARN, Log1, Log2
log4perl.filter.Filter1 = MyApp::Log::Filter1
log4perl.filter.Filter2 = MyApp::Log::Filter2
log4perl.appender.Log1 = Log::Log4perl::Appender::Screen
log4perl.appender.Log1.Filter = Filter1
log4perl.appender.Log2 = Log::Log4perl::Appender::File
log4perl.appender.Log2.Filter = Filter2