From: Craig <cr...@po...> - 2008-05-23 02:23:23
|
Hi. I have an app where I want to log the following: stdout: ERROR stderr: ERROR file: INFO Also, I need to be able to change the level for stdout during run-time. I have a simple test script with the following config: $conf = { 'log4perl.logger' => "ERROR, Screen, OutError, File", 'log4perl.filter.Info' => 'Log::Log4perl::Filter::LevelRange', 'log4perl.filter.Info.LevelMin' => 'INFO', 'log4perl.filter.Info.LevelMax' => 'FATAL', 'log4perl.filter.Info.AcceptOnMatch' => 'true', 'log4perl.filter.Warn' => 'Log::Log4perl::Filter::LevelRange', 'log4perl.filter.Warn.LevelMin' => 'WARN', 'log4perl.filter.Warn.LevelMax' => 'FATAL', 'log4perl.filter.Warn.AcceptOnMatch' => 'true', "log4perl.appender.Screen" => "Log::Log4perl::Appender::Screen", "log4perl.appender.Screen.stderr" => "0", "log4perl.appender.Screen.layout" => "Log::Log4perl::Layout::PatternLayout", "log4perl.appender.Screen.layout.ConversionPattern" => 'ok: %p>%M-%L: %m%n', "log4perl.appender.OutError" => "Log::Log4perl::Appender::Screen", "log4perl.appender.OutError.Filter" => 'Warn', "log4perl.appender.OutError.stderr" => "1", "log4perl.appender.OutError.layout" => "Log::Log4perl::Layout::PatternLayout", "log4perl.appender.OutError.layout.ConversionPattern" => 'ok: %p>%M-%L: %m%n', "log4perl.appender.File" => "Log::Log4perl::Appender::File", "log4perl.appender.File.Filter" => 'Info', "log4perl.appender.File.mode" => 'append', "log4perl.appender.File.filename" => "app-multi.log", "log4perl.appender.File.layout" => "Log::Log4perl::Layout::PatternLayout", "log4perl.appender.File.layout.ConversionPattern" => '%p>%M-%L: %m%n' }; Log::Log4perl::init($conf); $logger = get_logger($name); ... ######################### Problem is that I need to *always* send info (and "up") messages to the file and error (and "up") to stderr regardless of what the root logger level is set to. But, I also need to be able to change the stdout level on the fly. I don't want to set the default root level to anything less than ERROR, which means that only error and up will then be sent to the file. (Basically, I have a "verbose" switch on the app where I turn down the level for stdout. But, the default should be pretty non-chatty.) Does this all make sense? (Not sure if I explained it very well.) Any ideas would be appreciated! Thanx Craig |