From: Tom B. <tbo...@tr...> - 2005-02-08 19:14:03
|
Hello, I am working on getting log4perl incorporated into my perl scripts. I came across the following bug: It looks like for the LevelRange filter the dynamic code isn't working When trying to use a filter (Log::Log4perl::Filter::LevelRange) I was attempting to set the Min value dynamically. log4perl.filter.ScreenFilter.LevelMin = sub { $screen_log_level; } This was returning the error message that 'sub { $screen_log_level; }' was not a valid error level (DEBUG|INFO|WARN|ERROR|FATAL|ALL|OFF) in LevelRange.pm line 41 I then attempted to set a variable in the front of the config file screen_logging_level = sub { $screen_log_level; } log4perl.filter.ScreenFilter.LevelMin = ${screen_logging_level} and received the same error message. Anyhow, I am working getting log4perl incorporated in with many of my perl scripts. In general I am going to use three different appenders. log4perl.rootLogger = DEBUG, LOGFILE, SCREEN, EMAIL I want to set the level of SCREEN at runtime. (--verbose --verbose) etc without changing the levels of LOGFILE or EMAIL. As well allow you to shut off logging while running (--no-email-log) if you want. I can't figure out how to do this correctly. My first thought was to set the logging level per appender, but I can't figure out how to correctly do this. The only method I can find will change all appenders for a given package and I only want to change one. My next thought was to create separate lines in the config file like log4perl.rootLogger = DEBUG, LOGFILE log4perl.rootLogger = sub { "$screen_log_level, SCREEN" } However this changes LOGFILE level as well. Then I tried filters in the config file and noticed that I couldn't set the MinLevel dynamically (see bug above). Next I thought maybe I could dynamically create the filter and attach it to the appender but I can't figure out how to get a hold of one of the appenders. The only option I have left is to completely embed the config file in the perl code but I like having the config outside of perl. Anyone have any thoughts on this? I'm using version 0.51 perl 5.8.3 on SUSE. Thanks, Tom |