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 |
From: Mike S. <log...@pe...> - 2003-05-29 01:19:16
|
From: Andrew Hammond <and...@su...> To: Mike Schilli <log...@pe...> Subject: Re: please help oh log-guru! :) Thankyou for the help, that makes a lot more sense to me now. I think I need 2 loggers, one of which should have 2 appenders. The goal is to have all the generic "logging" information going into the first logger with the 2 appenders (the root logger), and a second logger which _only_ gets sql specific stuff (the SQL logger). Here's what I've currently got. The root logger is working perfectly, but the SQL logger isn't getting _any_ messages. I must be doing something wrong... log4perl.logger = DEBUG, LOGFILE, STDERR log4perl.appender.LOGFILE = Log::Dispatch::File log4perl.appender.LOGFILE.Threshold = WARN log4perl.appender.LOGFILE.filename = error_log.txt log4perl.appender.LOGFILE.mode = append log4perl.appender.LOGFILE.layout = PatternLayout log4perl.appender.LOGFILE.layout.ConversionPattern = \ %d [%r] %c %F:%L (%M) - %m%n log4perl.appender.STDERR = Log::Dispatch::Screen log4perl.appender.STDERR.Threshold = INFO log4perl.appender.STDERR.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.STDERR.layout.ConversionPattern = %d - %m%n log4perl.logger.SQL = DEBUG, SQL log4perl.appender.SQL = Log::Dispatch::File log4perl.appender.SQL.Threshold = DEBUG log4perl.appender.SQL.filename = sqllog.sql log4perl.appender.SQL.mode = write log4perl.appender.SQL.layout = PatternLayout log4perl.appender.SQL.layout.ConversionPattern = %m%n code: Log::Log4perl->init('webpanel_log.conf'); our $log = get_logger(); our $sqllog = get_logger('sql'); $log->info('Starting Run'); # goes to root logger, not seen by sql logger: perfect! $sqllog->debug($query); # should end up in sqllog.sql file, but doesn't... :( where $query is a really long and involved SQL query that the code generates for me... Mike Schilli wrote: >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 > > > > |