From: Mike S. <log...@pe...> - 2003-05-23 20:45:01
|
On Fri, 23 May 2003, Andrew Hammond wrote: > My goal is to have $log with a pair of appenders (one that goes into an > error log and triggers at level WARN, the other which goes to STDERR and > triggers at INFO), and $sqllog that goes to a completely seperate log. > > config file is: > > log4perl.logger = INFO, LOGFILE > log4perl.appender.LOGFILE = Log::Dispatch::File > log4perl.appender.LOGFILE.filename = error_log.txt > log4perl.appender.LOGFILE.mode = append > log4perl.appender.LOGFILE.layout = PatternLayout > log4perl.appender.LOGFILE.layout.ConversionPattern = [%r] %c %F:%L (%M) > - %m%n > > log4perl.category.STDERR = WARN, STDERR > log4perl.appender.STDERR = Log::Dispatch::Screen > log4perl.appender.STDERR.layout = > Log::Log4perl::Layout::PatternLayout > log4perl.appender.STDERR.layout.ConversionPattern = %d %c %F:%L (%M) - %m%n > > log4perl.logger.sql = DEBUG, SQL > log4perl.appender.SQL = Log::Dispatch::File > log4perl.appender.SQL.filename = sqllog.sql > log4perl.appender.SQL.mode = write > log4perl.appender.SQL.layout = PatternLayout > log4perl.appender.SQL.layout.ConversionPattern=%m%n Your categories (or loggers) look kind of strange: log4perl.category.STDERR defines a logger which would respond only if you obtained a logger via our $log = get_logger('STDERR'); # ??? questionable ??? but that's probably not what you want. Categories are for defining which parts of the system you want logging enabled and they're usually set to the class the code is located in (like "Foo::Bar"). Since you seem to want to enable logging across the system (in the "root category" in Log4perl speak) you should leave out the category name entirely. Also, what you seem to want is to have *one* logger and multiple appenders (I replaced 'category' by 'logger' because that's the newer way, but they're synonyms): log4perl.logger = DEBUG, LOGFILE, STDERR, SQL And, get rid of these lines # Remove those log4perl.category.STDERR = WARN, STDERR log4perl.logger.sql = DEBUG, SQL If your appenders have different thresholds (WARN, DEBUG etc.), you can accomplish that via setting an appender threshold: log4perl.appender.STDERR.Threshold = WARN log4perl.appender.sql.Threshold = DEBUG Give it a whirl ... -- Mike Mike Schilli log...@pe... http://perlmeister.com http://log4perl.sourceforge.net |