You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(38) |
Sep
(126) |
Oct
(23) |
Nov
(72) |
Dec
(36) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(76) |
Feb
(32) |
Mar
(19) |
Apr
(6) |
May
(54) |
Jun
(40) |
Jul
(45) |
Aug
(35) |
Sep
(51) |
Oct
(67) |
Nov
(10) |
Dec
(50) |
2004 |
Jan
(51) |
Feb
(22) |
Mar
(22) |
Apr
(28) |
May
(53) |
Jun
(99) |
Jul
(38) |
Aug
(49) |
Sep
(23) |
Oct
(29) |
Nov
(30) |
Dec
(48) |
2005 |
Jan
(15) |
Feb
(21) |
Mar
(25) |
Apr
(16) |
May
(131) |
Jun
|
Jul
(8) |
Aug
(5) |
Sep
(15) |
Oct
|
Nov
(15) |
Dec
(12) |
2006 |
Jan
(15) |
Feb
(20) |
Mar
(8) |
Apr
(10) |
May
(3) |
Jun
(16) |
Jul
(15) |
Aug
(11) |
Sep
(17) |
Oct
(27) |
Nov
(11) |
Dec
(12) |
2007 |
Jan
(19) |
Feb
(18) |
Mar
(33) |
Apr
(4) |
May
(15) |
Jun
(22) |
Jul
(19) |
Aug
(20) |
Sep
(14) |
Oct
(4) |
Nov
(34) |
Dec
(11) |
2008 |
Jan
(8) |
Feb
(18) |
Mar
(2) |
Apr
(4) |
May
(26) |
Jun
(9) |
Jul
(8) |
Aug
(8) |
Sep
(3) |
Oct
(17) |
Nov
(14) |
Dec
(4) |
2009 |
Jan
(6) |
Feb
(41) |
Mar
(21) |
Apr
(10) |
May
(21) |
Jun
|
Jul
(8) |
Aug
(4) |
Sep
(3) |
Oct
(8) |
Nov
(6) |
Dec
(5) |
2010 |
Jan
(14) |
Feb
(13) |
Mar
(7) |
Apr
(12) |
May
(4) |
Jun
(1) |
Jul
(11) |
Aug
(5) |
Sep
|
Oct
(1) |
Nov
(10) |
Dec
|
2011 |
Jan
(7) |
Feb
(3) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(1) |
Jul
(6) |
Aug
(6) |
Sep
(10) |
Oct
(5) |
Nov
(4) |
Dec
(5) |
2012 |
Jan
(4) |
Feb
(5) |
Mar
(1) |
Apr
(7) |
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
(5) |
Oct
(5) |
Nov
(4) |
Dec
(5) |
2013 |
Jan
(6) |
Feb
|
Mar
(14) |
Apr
(9) |
May
(3) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
(4) |
Dec
(6) |
2014 |
Jan
|
Feb
(1) |
Mar
(10) |
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
(1) |
Nov
|
Dec
(4) |
2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Ronald F. <yn...@mm...> - 2009-03-10 10:59:40
|
On Mon, 09 Mar 2009 12:09 -0700, "Mike Schilli" <m...@pe...> wrote: > A, gotcha, I forgot that you have a long-running process and want to > switch log files for every request. To do that, you can write your own > appender (it's very easy, check > http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl/FAQ.pm#How_can_I_write_my_own_appender?) > or, alternatively, when you get a request, run > > Log::Log4perl->appender_by_name("LogApp")->file_switch("log$$.log"); > > given that "LogApp" is the name of the appender in your Log4perl > configuration (if you're using :easy, its name is "app001"). I like the use of file_switch, because this seems to map perfectly well to the design I have right now. If I use easy_init like this: Log::Log4perl->easy_init( {level => $log_level, file => 'STDOUT', layout => '%.1p %d{HH:mm} %M(%L) %m%n' }, {level => $log_level, file => ">main.log", layout => '%.1p %d{dd.MM. HH:mm:ss (EEE)} %M(%L) %m%n' } {level => $log_level, file => '>dummy.log'), layout => '%.1p %d{HH:mm} %M(%L) %m%n' }, ); I guess the name of the "dummy.log" appender then is app003, so I would have to switch it by Log::Log4perl->appender_by_name('app003')->file_switch(get_request_logfile()); or alternatively that I explicitly provide logger names, i.e. Log::Log4perl->easy_init( {level => $log_level, file => 'STDOUT', layout => '%.1p %d{HH:mm} %M(%L) %m%n' }, {level => $log_level, file => ">main.log", layout => '%.1p %d{dd.MM. HH:mm:ss (EEE)} %M(%L) %m%n' } {level => $log_level, file => '>dummy.log'), layout => '%.1p %d{HH:mm} %M(%L) %m%n', name => 'requestlogger' }, ); ... Log::Log4perl->appender_by_name('requestlogger')->file_switch(get_request_logfile()); Is this correct? Regards, Ronald -- Ronald Fischer <ro...@em...> + If a packet hits a pocket on a socket on a port, + and the bus is interrupted and the interrupt's not caught, + then the socket packet pocket has an error to report. + (cited after Peter van der Linden) |
From: Mike S. <m...@pe...> - 2009-03-06 16:53:10
|
On Fri, 6 Mar 2009, Ronald Fischer wrote: > I understand how to do it in a config file, but I don't see how to do > it in my code. Probably it is not possible at all with easy_init > (which I would like to continue to use) easy_init() and init() are using the same underlying internal Log4perl API functions, so it doesn't matter which one you're using. > # This is my current initialization > Log::Log4perl->easy_init( > # ... Details left out > ); > # Now define the request-specific logger > > use Log::Log4perl::Layout; > use Log::Log4perl::Level; > my $req_logger= Log::Log4perl->get_logger(???); Since you don't want categories, use the root logger here: my $req_logger= Log::Log4perl->get_logger(""); > my $req_appender = Log::Log4perl::Appender->new( > "Log::Log4perl::Appender::File", > name => "???", You can omit the name. > mode => 'clobber', > utf8 => 1, > create_at_logtime => 1 > filename => \&get_current_logfile); # ??? You don't want to pass a reference here, you want to call the function right here: filename => get_current_logfile() ); and define it like sub get_current_logfile { return "logfile.dat"; } or whatever fance logic you want it to use, but it needs to return the name of the file. So, a working version of what you want would look something like this: use strict; use Log::Log4perl qw(:easy); # This is my current initialization Log::Log4perl->easy_init($DEBUG); use Log::Log4perl::Layout; use Log::Log4perl::Level; my $req_logger= Log::Log4perl->get_logger(""); my $req_appender = Log::Log4perl::Appender->new( "Log::Log4perl::Appender::File", mode => 'clobber', utf8 => 1, create_at_logtime => 1, filename => get_current_logfile()); $req_appender->layout(Log::Log4perl::Layout::SimpleLayout->new()); $req_logger->add_appender($req_appender); DEBUG "waah"; ########################################### sub get_current_logfile { ########################################### return "logfile.dat"; } One more thing: A logger (the root logger in your case) can only have one level. So if you initialize with easy_init($DEBUG), that's the level it's gonna have. If you want different levels for the file appender you're setting up manually, use appender thresholds or a filter. Hope that helps! -- Mike Mike Schilli m...@pe... |
From: Ronald F. <yn...@mm...> - 2009-03-06 09:00:33
|
Resent of my posting from 24 Feb which seems to have been lost. ----- Original message ----- From: "Ronald Fischer" <yn...@mm...> To: "Mike Schilli" <m...@pe...> Cc: "Mike Schilli" <m...@pe...>, "log4perl MailingList" <log...@li...> Date: Tue, 24 Feb 2009 09:52:06 +0100 Subject: Re: [log4perl-devel] Appender::File and Layout question On Mon, 23 Feb 2009 08:34 -0800, "Mike Schilli" <m...@pe...> wrote: > > The other problem is that I would strongly prefer a solution without > > l4p configuration file. The reason is that one requirement for our > > application was "one config file only", so we have an application > > specific configuration file, so I'm using easy_init to initialize the > > logging. > > Everything you can do in a configuration file can be done in code with > the Log4perl API, problem is just that it might get confusing if you're > trying to figure out what's going on by looking at the configuration > file, while application code is pulling the rug under it :). Right, but this is a decision I don't want to (actually, I must not) decide by myself, but this must be done by the project leader, which means that I have to at least demonstrate both ways. Thanks to your explanations, I understand how to do it in a config file, but I don't see how to do it in my code. Probably it is not possible at all with easy_init (which I would like to continue to use) - at least I can't find anything suitable in the perldoc of Log::Log4perl. There is something in the section "Advanced Perl Configuration", but I don't see how to use it in my case. This is how far I got: # This is my current initialization Log::Log4perl->easy_init( # ... Details left out ); # Now define the request-specific logger use Log::Log4perl::Layout; use Log::Log4perl::Level; my $req_logger= Log::Log4perl->get_logger(???); my $req_appender = Log::Log4perl::Appender->new( "Log::Log4perl::Appender::File", name => "???", mode => 'clobber', utf8 => 1, create_at_logtime => 1 filename => \&get_current_logfile); # ??? $req_appender->layout(Log::Log4perl::Layout::PatternLayout->new("...")); $req_logger->add_appender($req_appender); $req_logger->level($INFO); And when it comes to logging something to the request logger, I would write i.e. $req_logger->loginfo("my message goes here"); I don't know whether the general idea is right or whether there is a shorter way to write it, but still there are a few open points, which I have marked in my code above with ???. First, what category string should I pass to get_logger? We don't work with categories, and we have none defined with easy_init, so it would make sense to me to pass the "default category". Could this be done by passing, say, the null string? Second, what is the "name" parameter used for when creating the Appender. I found the usage of name => in the perldoc, but what's its purpose? Finally, is my usage of passing a code reference to filename correct? Kind regards, Ronald > > -- Mike > > Mike Schilli > m...@pe... -- Ronald Fischer <ro...@em...> + If a packet hits a pocket on a socket on a port, + and the bus is interrupted and the interrupt's not caught, + then the socket packet pocket has an error to report. + (cited after Peter van der Linden) -- Ronald Fischer <ro...@em...> + If a packet hits a pocket on a socket on a port, + and the bus is interrupted and the interrupt's not caught, + then the socket packet pocket has an error to report. + (cited after Peter van der Linden) |
From: Robert J. <yad...@sn...> - 2009-02-26 12:55:13
|
Mike Schilli m-at-perlmeister.com |log4perl_sourceforge| wrote: > On Tue, 24 Feb 2009, Robert Jacobson wrote: > >> Those are mostly the expected values from the Layout I specified >> (time, log level, script name, hostname, PID, ?????, message). > > That's peculiar ... what does your layout look like? > > It's hard to diagnose the problem without code that reproduces it, can > you post a stripped-down version of your appender? I attached the appender code (full version), a configuration file, and a test program in the first post I made. I could understand how you'd want a stripped-down version of the appender :) I wasn't sure what would happen if I stripped it down -- but it turns out that even with only two subs defined (new and post_init), the appender exhibits the problem of persistent DB connections. The stripped-down version of DBI_Buffer is attached, along with the test program and config. (again, modify the database config to match your database). For the error "called 7 bind variables when 6 are needed...", I added a little debug to DBI.pm (while still using my subclassed appender). With the "l4_depends_on" code in the stripped-down DBI_Buffer.pm i.e.: if ($self->{errorappender}) { # Pass back the appender to be synchronized as a dependency # to the configuration file parser push @{$p{l4p_depends_on}}, $self->{errorappender}; push @{$p{l4p_post_config_subs}}, sub { $self->post_init() }; } Then $p in DBI::calculate_bind_values shows the message as an array, e.g.: calculate_bind_values Dump p: $VAR1 = { 'log4p_level' => 'INFO', 'log4p_category' => 'ANS.component', 'level' => 1, 'name' => 'Database', 'message' => [ 'Starting ....' ] }; I thought the message array ref would get compressed to a scalar string value, but that doesn't seem to be the case. I tried messing with the warp_message values of the Logfile and Database appenders, but I still end up with 7 bind values no matter what warp_message setting I use. -- Rob |
From: Mike S. <m...@pe...> - 2009-02-26 00:42:56
|
On Tue, 24 Feb 2009, Robert Jacobson wrote: > Those are mostly the expected values from the Layout I specified > (time, log level, script name, hostname, PID, ?????, message). That's peculiar ... what does your layout look like? It's hard to diagnose the problem without code that reproduces it, can you post a stripped-down version of your appender? -- Mike Mike Schilli m...@pe... > Robert Jacobson wrote: > >> If I add equivalent code to my existing conditional for the definition >> of errorappender, i.e.: >> >> if ($self->{errorappender}) { >> # Pass back the appender to be synchronized as a dependency >> # to the configuration file parser >> push @{$p{l4p_depends_on}}, $self->{errorappender}; >> push @{$p{l4p_post_config_subs}}, sub { $self->post_init() }; >> } >> >> Then I get this error from Log::Log4perl::Appender::DBI: >> >> Log4perl: DBI appender failed to reconnect to database after 1 attempt >> at init_and_watch.pl line 10 > > I added some debug to DBI.pm and found that when I add the "depends_on" > code, the sub in DBI query_execute gets called with extra arguments. I > turned on the warn to print out the DBI::errstr and found that it isn't > really a connection error, it's a failure to execute the DBI statement: > > Exe: failed: called with 7 bind variables when 6 are needed at > .../Log/Log4perl/Appender/DBI.pm line 159. > > (line number different because of my local edits to DBI.pm) > > Adding a "Dumper" for qmarks: > > $VAR1 = '2009-055/17:35:41'; > $VAR2 = 'INFO'; > $VAR3 = 'component.pl'; > $VAR4 = 'ansdev2'; > $VAR5 = '25227'; > $VAR6 = 'ARRAY(0x813274c)'; > $VAR7 = 'Starting ....'; > |
From: Robert J. <yad...@sn...> - 2009-02-24 17:40:07
|
Robert Jacobson wrote: > If I add equivalent code to my existing conditional for the definition > of errorappender, i.e.: > > if ($self->{errorappender}) { > # Pass back the appender to be synchronized as a dependency > # to the configuration file parser > push @{$p{l4p_depends_on}}, $self->{errorappender}; > push @{$p{l4p_post_config_subs}}, sub { $self->post_init() }; > } > > Then I get this error from Log::Log4perl::Appender::DBI: > > Log4perl: DBI appender failed to reconnect to database after 1 attempt > at init_and_watch.pl line 10 I added some debug to DBI.pm and found that when I add the "depends_on" code, the sub in DBI query_execute gets called with extra arguments. I turned on the warn to print out the DBI::errstr and found that it isn't really a connection error, it's a failure to execute the DBI statement: Exe: failed: called with 7 bind variables when 6 are needed at .../Log/Log4perl/Appender/DBI.pm line 159. (line number different because of my local edits to DBI.pm) Adding a "Dumper" for qmarks: $VAR1 = '2009-055/17:35:41'; $VAR2 = 'INFO'; $VAR3 = 'component.pl'; $VAR4 = 'ansdev2'; $VAR5 = '25227'; $VAR6 = 'ARRAY(0x813274c)'; $VAR7 = 'Starting ....'; Those are mostly the expected values from the Layout I specified (time, log level, script name, hostname, PID, ?????, message). Where the heck did that "ARRAY" string come from? I checked using ref(); it really is a string of characters and not an actual array ref. -- Rob |
From: Ronald F. <yn...@mm...> - 2009-02-24 08:52:14
|
On Mon, 23 Feb 2009 08:34 -0800, "Mike Schilli" <m...@pe...> wrote: > > The other problem is that I would strongly prefer a solution without > > l4p configuration file. The reason is that one requirement for our > > application was "one config file only", so we have an application > > specific configuration file, so I'm using easy_init to initialize the > > logging. > > Everything you can do in a configuration file can be done in code with > the Log4perl API, problem is just that it might get confusing if you're > trying to figure out what's going on by looking at the configuration > file, while application code is pulling the rug under it :). Right, but this is a decision I don't want to (actually, I must not) decide by myself, but this must be done by the project leader, which means that I have to at least demonstrate both ways. Thanks to your explanations, I understand how to do it in a config file, but I don't see how to do it in my code. Probably it is not possible at all with easy_init (which I would like to continue to use) - at least I can't find anything suitable in the perldoc of Log::Log4perl. There is something in the section "Advanced Perl Configuration", but I don't see how to use it in my case. This is how far I got: # This is my current initialization Log::Log4perl->easy_init( # ... Details left out ); # Now define the request-specific logger use Log::Log4perl::Layout; use Log::Log4perl::Level; my $req_logger= Log::Log4perl->get_logger(???); my $req_appender = Log::Log4perl::Appender->new( "Log::Log4perl::Appender::File", name => "???", mode => 'clobber', utf8 => 1, create_at_logtime => 1 filename => \&get_current_logfile); # ??? $req_appender->layout(Log::Log4perl::Layout::PatternLayout->new("...")); $req_logger->add_appender($req_appender); $req_logger->level($INFO); And when it comes to logging something to the request logger, I would write i.e. $req_logger->loginfo("my message goes here"); I don't know whether the general idea is right or whether there is a shorter way to write it, but still there are a few open points, which I have marked in my code above with ???. First, what category string should I pass to get_logger? We don't work with categories, and we have none defined with easy_init, so it would make sense to me to pass the "default category". Could this be done by passing, say, the null string? Second, what is the "name" parameter used for when creating the Appender. I found the usage of name => in the perldoc, but what's its purpose? Finally, is my usage of passing a code reference to filename correct? Kind regards, Ronald > > -- Mike > > Mike Schilli > m...@pe... -- Ronald Fischer <ro...@em...> + If a packet hits a pocket on a socket on a port, + and the bus is interrupted and the interrupt's not caught, + then the socket packet pocket has an error to report. + (cited after Peter van der Linden) |
From: Robert J. <yad...@sn...> - 2009-02-23 20:01:22
|
This is related to the thread "Intermittent problems when using signal to reread log configuration", but it focuses more on where I think the problem is (i.e. my code). I'm hoping someone will be able to tell me where I'm going wrong! I'm having some trouble with a subclass of the DBI appender I have written. I call it "DBI_Buffer" (attached). It is basically a wrapper around the DBI appender to handle buffering when the database is down. It does a ping for every log message (inefficient, I know!). If the ping fails, it attempts to reconnect (up to X configured number of times). If it fails to reconnect, it stores log messages in an array. It then periodically checks to see if the database has come back up. When the connection is restored, it flushes the buffered messages to the database. (BTW, if someone knows a better way to prevent blocking when attempting to log while the database is down, I'd love to hear it!) I'm also using init_and_watch to reread my Log4perl config when the process receives SIGHUP. If I use the included DBI appender, when I send a SIGHUP to any perl process using that appender, it closes the existing connections and makes new ones. But when I am using my DBI_Buffer appender, it doesn't close the existing database connections. It does however make new ones, and logging continues to work. However, since the connections to the DB stick around basically forever -- eventually I run out of connections! Unfortunately the error I get is not usually "Too many connections"; it is instead: Can't call method "log" on an undefined value at /opt/ActivePerl-5.8/lib/site_perl/5.8.7/Log/Log4perl/Appender.pm line 189. I'm puzzled why I get this misleading error, but, well at least I know it is because I have run out of mysql connections. It seems to perhaps be related to the post_init() check I do (which I borrowed from Log::Log4perl::Appender::Synchronized). If the user wants to log database errors to a local logfile, they define an "errorappender" in the DBI_Buffer config. What's telling is that if I remove the "errorappender" definition from the config (thus removing the need to call post_init), I don't have a problem with stupidly persistent DB connections. I think this is a clue: Synchronized has this line of code: push @{$options{l4p_depends_on}}, $self->{appender}; But I do not. If I add equivalent code to my existing conditional for the definition of errorappender, i.e.: if ($self->{errorappender}) { # Pass back the appender to be synchronized as a dependency # to the configuration file parser push @{$p{l4p_depends_on}}, $self->{errorappender}; push @{$p{l4p_post_config_subs}}, sub { $self->post_init() }; } Then I get this error from Log::Log4perl::Appender::DBI: Log4perl: DBI appender failed to reconnect to database after 1 attempt at init_and_watch.pl line 10 (minimal test program and config attached as well) To reproduce, you need a mysql server and associated tables. Edit the attached config to match. Then run init_and_watch.pl in the background. Use a mysql client to look at the current connections. For mysql 4.1 and 5.x, this works: show processlist; Send a SIGHUP to the running perl process, and check the mysql processlist again. There will be a new one. --------- Side question (somewhat related): both DBI and DBI_Buffer seem to make connections to databases aren't really necessary. In other words, if all of these conditions are true: 1) "Database1" and "Database2" are both defined in the config file as DBI appenders 2) Two categories are defined that use both Database appenders, e.g.: log4perl.category.DB1 = INFO, Database1 log4perl.category.DB2 = INFO, Database2 3) Run a program that only uses the "DB1" category, e.g: my $logger = get_logger("DB1"); Then it it makes connections to both databases, even though only DB1 is used. Is this expected behavior? I know this behavior isn't causing my problem, because if I SIGHUP a program using the DBI appender, the connections are remade instead of hanging around needlessly as when I use DBI_Buffer. I'm just curious. -- Rob |
From: Mike S. <m...@pe...> - 2009-02-23 18:48:25
|
On Mon, 23 Feb 2009, Robert Jacobson wrote: > Apparently my appender is not closing its dbh filehandles. I'm going > to start a separate thread, since the problem is something totally > different (in my code, probably). I apologize for my inadequate > testing :( No problem at all, glad we've found an explanation :) -- Mike Mike Schilli m...@pe... |
From: Robert J. <yad...@sn...> - 2009-02-23 17:39:09
|
Ah, apparently I *had* left some appenders using DBI_Buffer (DBI appender subclass) in my config. I retested a bunch of things today and I could not reproduce the error unless I had my DBI_Buffer appender in the config. Further investigation showed that the mysql server was reaching its maximum number of allowed connections (currently set at 250). Apparently my appender is not closing its dbh filehandles. I'm going to start a separate thread, since the problem is something totally different (in my code, probably). I apologize for my inadequate testing :( -- Rob |
From: Mike S. <m...@pe...> - 2009-02-23 16:34:25
|
On Mon, 23 Feb 2009, Ronald Fischer wrote: > I see, and I guess get_request_name must be in package main so that > the logging package can find it? Either that or you call the fully qualified name, Foo::Bar::get_request_name. > There are times where there is no request being processed, but still > logging occurs. One solution would be to have get_request_name() in > this case return a dummy name (say: '_none_'), which would result in > a file mylog._none_.log, which I then simply can discard. But maybe > you have a more elegant solution for this? Looks perfect to me. > The other problem is that I would strongly prefer a solution without > l4p configuration file. The reason is that one requirement for our > application was "one config file only", so we have an application > specific configuration file, so I'm using easy_init to initialize the > logging. Although I can clearly see advantages of using a separate > config file for logging, it would violate a requirement for this > project. Sure, maybe I can convince the customer to change this > requirement, but your solution could be done interally, I would be > happier. Everything you can do in a configuration file can be done in code with the Log4perl API, problem is just that it might get confusing if you're trying to figure out what's going on by looking at the configuration file, while application code is pulling the rug under it :). -- Mike Mike Schilli m...@pe... |
From: Ronald F. <yn...@mm...> - 2009-02-23 08:53:14
|
On Fri, 20 Feb 2009 10:41 -0800, "Mike Schilli" <m...@pe...> wrote: > On Fri, 20 Feb 2009, Ronald Fischer wrote: > >> log4perl.logger = DEBUG, FooApp, BarApp, AnotherAppender > > > > This is valid Perl code????? So I have to the left of the assignment a > > catenation, and to the right the comma operator? > > Of course not, it's l4p config syntax. > > >> # ... > >> log4perl.appender.AnotherAppender.filename = \ > >> sub { "mylog." . get_request_name() . ".log" } > > > > Here too I don't understand the syntax. > > The right-hand side of an assignment in l4p config syntax can be a > perl code reference. I see, and I guess get_request_name must be in package main so that the logging package can find it? There are two (hopefully minor) problems left: There are times where there is no request being processed, but still logging occurs. One solution would be to have get_request_name() in this case return a dummy name (say: '_none_'), which would result in a file mylog._none_.log, which I then simply can discard. But maybe you have a more elegant solution for this? The other problem is that I would strongly prefer a solution without l4p configuration file. The reason is that one requirement for our application was "one config file only", so we have an application specific configuration file, so I'm using easy_init to initialize the logging. Although I can clearly see advantages of using a separate config file for logging, it would violate a requirement for this project. Sure, maybe I can convince the customer to change this requirement, but your solution could be done interally, I would be happier. Ronald -- Ronald Fischer <ro...@em...> + If a packet hits a pocket on a socket on a port, + and the bus is interrupted and the interrupt's not caught, + then the socket packet pocket has an error to report. + (cited after Peter van der Linden) |
From: Mike S. <m...@pe...> - 2009-02-22 09:32:45
|
On Sat, 21 Feb 2009, Robert Jacobson wrote: > I am using ActiveState perl on CentOS 4.2 and RHEL4; they both exhibit > the problem. I haven't tried Windows; does SIGHUP even exist there? > (nvm, doesn't matter :) ) Never mind, I was assuming you were using Windows because I've never used ActiveState Perl on Unix! :) -- Mike Mike Schilli m...@pe... |
From: Robert J. <yad...@sn...> - 2009-02-21 23:41:33
|
Mike Schilli m-at-perlmeister.com |log4perl_sourceforge| wrote: > On Fri, 20 Feb 2009, Robert Jacobson wrote: >>> I wonder what kind of config change would cause >>> this. Are you removing an appender by any chance? >> >> Nope, usually I'm only changing the log level. >> >> But I can reproduce the error without changing anything in the config, >> too. > > Interesting ... is there a way you could send a narrowed-down test > program to let me reproduce this? I can try, but it'll have to wait until I'm at work again. > I'd be interested to find out what's > causing this. Also, is this only happening on Windows with ActiveState > Perl or have you seen it happen on other OS and perl distros as well? I am using ActiveState perl on CentOS 4.2 and RHEL4; they both exhibit the problem. I haven't tried Windows; does SIGHUP even exist there? (nvm, doesn't matter :) ) -- Rob |
From: Mike S. <m...@pe...> - 2009-02-21 17:27:09
|
On Fri, 20 Feb 2009, Robert Jacobson wrote: >> I wonder what kind of config change would cause >> this. Are you removing an appender by any chance? > > Nope, usually I'm only changing the log level. > > But I can reproduce the error without changing anything in the config, too. Interesting ... is there a way you could send a narrowed-down test program to let me reproduce this? I'd be interested to find out what's causing this. Also, is this only happening on Windows with ActiveState Perl or have you seen it happen on other OS and perl distros as well? -- Mike Mike Schilli m...@pe... |
From: Mike S. <m...@pe...> - 2009-02-20 18:41:33
|
On Fri, 20 Feb 2009, Ronald Fischer wrote: > I tried the following code: > $nl = > Log::Log4perl::Appender::File->new( > filename => $logname, > mode => 'clobber', > utf8 => 1, > create_at_logtime => 1 > ); > $nl->layout(Log::Log4perl::Layout::PatternLayout->new('%C %m%n')); That won't work, you have to use Log4perl's appender wrapper around the real appender -- but this is just a theoretical exercise, I don't really recommend playing with Log4perl's internals. >> log4perl.logger = DEBUG, FooApp, BarApp, AnotherAppender > > This is valid Perl code????? So I have to the left of the assignment a > catenation, and to the right the comma operator? Of course not, it's l4p config syntax. >> # ... >> log4perl.appender.AnotherAppender.filename = \ >> sub { "mylog." . get_request_name() . ".log" } > > Here too I don't understand the syntax. The right-hand side of an assignment in l4p config syntax can be a perl code reference. > No, the app is running continually during days or weeks in a main > loop and polls for new requests. If a request is arriving, it is > decomposed into various pieces. Say a request R is coming, followed > by request S. The app first is analyzing R and decomposes it into > pieces according to some algorithm (let's call the pieces R1, R2, > R3). Then it does the next with request S (which might result into > pieces S1, S2, S3, S4). Then it schedules the pieces for execution. > One schedule might be: R1, S1, S2, R2, S3, S4, R3 and executes them. > While some "R"-piece is executed, logs should go to the "R.log" > file. While some "S"-piece is executed, logs should go to the > "S.log" file. That's alright, just a subroutine like get_request_name() shown above accordingly, so that it returns a unique name for every unique request or subrequest. -- Mike Mike Schilli m...@pe... |
From: Robert J. <yad...@sn...> - 2009-02-20 13:37:50
|
Mike Schilli m-at-perlmeister.com |log4perl_sourceforge| wrote: > Hmm, that's peculiar. I wonder what kind of config change would cause > this. Are you removing an appender by any chance? Nope, usually I'm only changing the log level. But I can reproduce the error without changing anything in the config, too. It does seem to only have a problem when the system is heavily loaded. Perhaps this is a race condition that is more likely when resources are heavily used? (just a guess, I really don't know) -- Rob |
From: Ronald F. <yn...@mm...> - 2009-02-20 09:02:17
|
On Thu, 19 Feb 2009 21:13 -0800, "Mike Schilli" <m...@pe...> wrote: > Actually, just for the record, you can set an appender's layout: > > $appender->layout($layout); # perldoc Log::Log4perl::Appender I tried the following code: $nl = Log::Log4perl::Appender::File->new( filename => $logname, mode => 'clobber', utf8 => 1, create_at_logtime => 1 ); $nl->layout(Log::Log4perl::Layout::PatternLayout->new('%C %m%n')); But when I write something with $nl->log(...), I don't see the layout applied. > > Now I would like to incorporate the possibility that in addition to > > that normal, continually going logfile, the logs occuring to each > > request should be written into a separate, request-specific logfile, > > so that, if we hav 100 requests on a day, we would end up having 100 > > extra logfiles in addition to the main logfile. > > Add another appender to your category and have it name its log > files according to a function get_request_name() that your > application provides: > > log4perl.logger = DEBUG, FooApp, BarApp, AnotherAppender This is valid Perl code????? So I have to the left of the assignment a catenation, and to the right the comma operator? > # ... > log4perl.appender.AnotherAppender.filename = \ > sub { "mylog." . get_request_name() . ".log" } Here too I don't understand the syntax. > I'm assuming that each 'request' starts the app anew. No, the app is running continually during days or weeks in a main loop and polls for new requests. If a request is arriving, it is decomposed into various pieces. Say a request R is coming, followed by request S. The app first is analyzing R and decomposes it into pieces according to some algorithm (let's call the pieces R1, R2, R3). Then it does the next with request S (which might result into pieces S1, S2, S3, S4). Then it schedules the pieces for execution. One schedule might be: R1, S1, S2, R2, S3, S4, R3 and executes them. While some "R"-piece is executed, logs should go to the "R.log" file. While some "S"-piece is executed, logs should go to the "S.log" file. This is a highly simplified example, and of course there are not only 2 requests per day, but many more. Ronald -- Ronald Fischer <ro...@em...> + If a packet hits a pocket on a socket on a port, + and the bus is interrupted and the interrupt's not caught, + then the socket packet pocket has an error to report. + (cited after Peter van der Linden) |
From: Mike S. <m...@pe...> - 2009-02-20 05:41:41
|
On Wed, 18 Feb 2009, wzh...@gm... wrote: > I have a script running, which can be stopped and restarted frequently. I > was able to get the file rotation working until I added > "log4perl.appender.RunMonitorLogFile.mode = append" to set the mode to > append, so the previous script run's log file doesn't get wiped out after a > restart of the script. It's not rotating anymore. Works for me. Here's a script for you to verify, call it a couple of times, then wait a minute, and call it again, and you'll see that it'll create test.log.1, test.log.2 etc. use strict; use Log::Log4perl qw(get_logger); my $conf = q( log4perl.category.Bar.Twix = WARN, Logfile log4perl.appender.Logfile = Log::Dispatch::FileRotate log4perl.appender.Logfile.filename = test.log log4perl.appender.Logfile.mode = append log4perl.appender.Logfile.DatePattern = yyyy-MM-dd-HH-MM log4perl.appender.Logfile.max = 5 log4perl.appender.Logfile.layout = \ Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = %d %m %n ); Log::Log4perl::init(\$conf); my $logger = get_logger("Bar::Twix"); $logger->error("Blah"); Try it out! -- Mike Mike Schilli m...@pe... |
From: Mike S. <m...@pe...> - 2009-02-20 05:13:28
|
On Thu, 19 Feb 2009, Ronald Fischer wrote: >> What you think is a 'logger' is really an appender in Log4perl lingo. An >> appender has no concept of a level like 'debug', only loggers do. > > I see, and that's why it also can't understand about layouts. Actually, just for the record, you can set an appender's layout: $appender->layout($layout); # perldoc Log::Log4perl::Appender > Now I would like to incorporate the possibility that in addition to > that normal, continually going logfile, the logs occuring to each > request should be written into a separate, request-specific logfile, > so that, if we hav 100 requests on a day, we would end up having 100 > extra logfiles in addition to the main logfile. Add another appender to your category and have it name its log files according to a function get_request_name() that your application provides: log4perl.logger = DEBUG, FooApp, BarApp, AnotherAppender # ... log4perl.appender.AnotherAppender.filename = \ sub { "mylog." . get_request_name() . ".log" } > Each of these extra logfiles is named after the request. This means > that whenever a new request arrives, we have to create a new logfile. > Since the requests are handled in parallel (but non-preemtive, i.e. no > threads involved), we have a central "logging handler" which knows > which request is the currently active one, and sends each logging > event to the standard log, plus to the request-specific one. I'm assuming that each 'request' starts the app anew. The continually going logfile appender is in 'append' mode and the request-based logfile appender is in 'clobber' mode. -- Mike Mike Schilli m...@pe... |
From: Mike S. <m...@pe...> - 2009-02-20 03:25:50
|
On Wed, 18 Feb 2009, Robert Jacobson wrote: > Most of the time (I'd guess ~80%), this works fine. When it doesn't > work, I get the following error on STDERR (even though I've wrapped > STDERR with a "Trapper" as described in the FAQ): > > Can't call method "log" on an undefined value at /opt/ActivePerl- > 5.8/lib/site_perl/5.8.7/Log/Log4perl/Appender.pm line 189. Hmm, that's peculiar. I wonder what kind of config change would cause this. Are you removing an appender by any chance? -- Mike Mike Schilli m...@pe... |
From: Ronald F. <yn...@mm...> - 2009-02-19 09:16:36
|
> What you think is a 'logger' is really an appender in Log4perl lingo. An > appender has no concept of a level like 'debug', only loggers do. I see, and that's why it also can't understand about layouts. > The reason why you get the error message 'on an undefined value' is an > internal autoload mechanism within the appender that's not defined in > your case. The error message is confusing and needs to be fixed, what it > should say instead is that logdebug() doesn't exist. I see. > Ideally, you would integrate your logging needs into the main log4perl > configuration -- can you explain in more detail why this isn't possible? Maybe it is and I just don't understand Log4perl well enough. We basically have an application which is running permanently (kind of a request server). It accepts requests, processes them, and returns the results. The processing of a single requests typically takes between a couple of minutes, not more than a few hours. The whole application logs its activity to a logfile and to stdout. This is what we have so far, and it is implemented via easy_init (which is, well, easy to use, but maybe not flexible enough): Log::Log4perl->easy_init( {level => $log_level, file => 'STDOUT', layout => '%.1p %d{HH:mm} %M(%L) %m%n' }, {level => $log_level, file => ">$logfile", layout => '%.1p %d{dd.MM. HH:mm:ss (EEE)} %M(%L) %m%n' } ); Now I would like to incorporate the possibility that in addition to that normal, continually going logfile, the logs occuring to each request should be written into a separate, request-specific logfile, so that, if we hav 100 requests on a day, we would end up having 100 extra logfiles in addition to the main logfile. Each of these extra logfiles is named after the request. This means that whenever a new request arrives, we have to create a new logfile. Since the requests are handled in parallel (but non-preemtive, i.e. no threads involved), we have a central "logging handler" which knows which request is the currently active one, and sends each logging event to the standard log, plus to the request-specific one. Any suggestion how I could implement this? Ronald -- Ronald Fischer <ro...@em...> + If a packet hits a pocket on a socket on a port, + and the bus is interrupted and the interrupt's not caught, + then the socket packet pocket has an error to report. + (cited after Peter van der Linden) |
From: Mike S. <m...@pe...> - 2009-02-19 00:07:46
|
On Wed, 18 Feb 2009, Ronald of Steiermark wrote: > Reason for this probably slightly unusual way of using Log::Log4perl > is the following: Hi Ronald, indeed, you're using Log4perl in a very unusual, not to say confusing way. What you think is a 'logger' is really an appender in Log4perl lingo. An appender has no concept of a level like 'debug', only loggers do. An appender only has a log() method, and it will normally log the message you're passing to it unconditionally. The reason why you get the error message 'on an undefined value' is an internal autoload mechanism within the appender that's not defined in your case. The error message is confusing and needs to be fixed, what it should say instead is that logdebug() doesn't exist. Ideally, you would integrate your logging needs into the main log4perl configuration -- can you explain in more detail why this isn't possible? -- Mike Mike Schilli m...@pe... > My application uses one common logging facility (hence the easy_init). > Certain parts of the application want to create occasionally their > various other logfiles with their own layout and shorter lifetime than > the common logging system (demonstrated here by > the variable $logger). This is the condensed code of my application > just for demonstrating my problem: > > use strict; > use warnings; > use Log::Log4perl qw(:easy); > use Log::Log4perl::Appender::File; > Log::Log4perl->easy_init({file=>'STDOUT',layout => '%d{HH:mm} %m%n', > level=>$DEBUG}); > my $logger=Log::Log4perl::Appender::File->new(filename => "dummy.log", > mode => 'clobber'); > $logger->log(message=>"test\n"); > $logger->layout(Log::Log4perl::Layout::PatternLayout->new('%c %C > %m%n')); > $logger->log(message => "abc"); > $logger->logdebug('xyz'); > > > Running this program results in a file dummy.log containing > > test > abc > > and the message > > Can't call method "logdebug" on an undefined value > > Now my questions: > > (1) Why does the second call to log() not obey the pattern layout I have > defined the line before? > After all, a Appender::File inherits from Appender, and hence layout() > should have the desired > effect. > > (2) Why does the error message say "on an undefined value", when $logger > (the object where method is > called on) is obviously not undefined? > > (3) I guess one of my mistakes is that Appender::File is not a suitable > logger type for my purpose. > Should I use a different logger instead, and if yes, which one? > > Ronald > -- > Ronald Fischer <aus...@ye...> > > There are 10 types of people in the world: those who understand binary and those who don't. > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel > |
From: Robert J. <yad...@sn...> - 2009-02-18 19:32:12
|
I have been using Log4perl for quite some time in a large project of mine. There are about 20 perl programs, all of which should always be running. I'm using init_and_watch to allow users to update the configuration file; i.e: # Init Log4perl Log::Log4perl->init_and_watch("../ANSlog.conf",'HUP'); $logger = get_logger("category") After updating the config file, I use a script to send SIGHUP to all the currently running processes (simple "kill -HUP <PID>"). Most of the time (I'd guess ~80%), this works fine. When it doesn't work, I get the following error on STDERR (even though I've wrapped STDERR with a "Trapper" as described in the FAQ): Can't call method "log" on an undefined value at /opt/ActivePerl-5.8/lib/site_perl/5.8.7/Log/Log4perl/Appender.pm line 189. And the perl program dies. I'm using ActivePerl 5.8.7 due to an restriction from a third-party Perl module; I can't update perl itself or use another perl distribution. I'm using Log4perl 1.20. The system is CentOS 4.2. My log4perl configuration is rather large, but it is below. I tried removing the Database appender from the configuration (i.e. leaving only the File appender "Logfile"), but it still happens without it. #----------------------------------------------------------------------- ## ## Root logger threshold and appenders ## log4perl.rootLogger = DEBUG ## ## Categories for each ANS module ## log4perl.category.ANS = INFO, Logfile log4perl.category.ANS.asistlog = INFO, Database log4perl.category.ANS.email = INFO, Database log4perl.category.ANS.event = INFO, Database log4perl.category.ANS.event.main = INFO log4perl.category.ANS.event.readconfig = INFO log4perl.category.ANS.event.forkchildren = INFO log4perl.category.ANS.event.refork = INFO log4perl.category.ANS.event.housekeeping = INFO log4perl.category.ANS.event.connopen = INFO log4perl.category.ANS.event.connclose = INFO log4perl.category.ANS.event.connquery = WARN log4perl.category.ANS.event.repeat = INFO log4perl.category.ANS.event.GetFieldValue = INFO log4perl.category.ANS.heartbeat = INFO, Database log4perl.category.ANS.htmlizer = INFO, Database # This category is special -- no inheritance from ANS category, # so messages only go to the alert database log4perl.category.htmlizer.sql = INFO, AlertDatabase log4perl.category.asistlog.sql = INFO, ASISTDatabase, DMZDatabase # log4perl.category.ANS.component = INFO, Database log4perl.category.ANS.satwatch = INFO, Database log4perl.category.ANS.satwatch.parse = INFO # ****** NOTE! DEBUG output for Catalog iS HUUUUUGE ******** log4perl.category.ANS.satwatch.catalog = INFO log4perl.category.ANS.satwatch.filter = INFO log4perl.category.ANS.satwatch.typehandler = INFO log4perl.category.ANS.satwatch.grouphandler = INFO log4perl.category.ANS.satwatch.registerhandler = INFO log4perl.category.ANS.satwatch.filterhandler = INFO log4perl.category.ANS.satwatch.eventhandler = INFO log4perl.category.ANS.satwatch.regexphandler = INFO log4perl.category.ANS.satwatch.occurshandler = INFO log4perl.category.ANS.satwatch.intervalhandler = INFO log4perl.category.ANS.satwatch.ignore = INFO log4perl.category.ANS.satwatch.watch = INFO log4perl.category.ANS.satwatch.clear = INFO log4perl.category.ANS.satwatch.flush = INFO log4perl.category.ANS.satwatch.flushnow = INFO log4perl.category.ANS.satwatch.cleaner = INFO log4perl.category.ANS.satwatch.cleanup = INFO log4perl.category.ANS.source = INFO, Database log4perl.category.ANS.target = INFO, SyncDatabase log4perl.category.ANS.trapper = INFO, Database ## ## Logfile appender ## log4perl.appender.Logfile = Log::Log4perl::Appender::File log4perl.appender.Logfile.filename = \ sub { if ($ENV{'ANSROOT'}) { \ return "$ENV{'ANSROOT'}/ANSlog.txt" \ } else { \ die "ENV{ANSROOT} not defined!" \ } } log4perl.appender.Logfile.mode = append log4perl.appender.Logfile.recreate = 1 log4perl.appender.Logfile.recreate_check_signal = USR1 #log4perl.appender.Logfile.recreate_check_interval = 5 log4perl.appender.Logfile.layout= Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = \ %d{yyyy-DDD/HH:mm:ss} %-5p %F{2} %P %m%n ## ## Screen Appender ## 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 = \ %d{yyyy-DDD/HH:mm:ss} %-5p %F{2} %P %m%n ## ## Database Appender ## # NOTE: DBI_Buffer uses all options from Log::Log4perl::Appender::DBI log4perl.appender.Database = Log::Log4perl::Appender::DBI log4perl.appender.Database.usePreparedStmt = 1 log4perl.appender.Database.layout = Log::Log4perl::Layout::NoopLayout log4perl.appender.Database.datasource = DBI:mysql:database=ansdb:host=localhost;mysql_auto_reconnect=1 log4perl.appender.Database.username = foo log4perl.appender.Database.password = bar log4perl.appender.Database.logbuffer = 4000 log4perl.appender.Database.errorappender= Logfile log4perl.appender.Database.errorstodatabase= 1 log4perl.appender.Database.sql = \ insert into anslog \ (date, loglevel, filename, hostname, PID, message) \ values (?,?,?,?,?,?) log4perl.appender.Database.params.1 = %d{yyyy-DDD/HH:mm:ss} log4perl.appender.Database.params.2 = %p log4perl.appender.Database.params.3 = %F{2} log4perl.appender.Database.params.4 = %H log4perl.appender.Database.params.5 = %P log4perl.appender.Database.params.6 = %m ## ## Alert Database Appender ## # NOTE: DBI_Buffer uses all options from Log::Log4perl::Appender::DBI log4perl.appender.AlertDatabase = DBI_Buffer log4perl.appender.AlertDatabase.layout = Log::Log4perl::Layout::NoopLayout log4perl.appender.AlertDatabase.warp_message = 0 log4perl.appender.AlertDatabase.datasource = DBI:mysql:database=ansdb:host=localhost;mysql_auto_reconnect=1 log4perl.appender.AlertDatabase.username = foo log4perl.appender.AlertDatabase.password = bar log4perl.appender.AlertDatabase.logbuffer = 4000 log4perl.appender.AlertDatabase.errorappender = Logfile log4perl.appender.AlertDatabase.errorstodatabase= 0 log4perl.appender.AlertDatabase.sql = \ insert into alerts \ (date, loglevel, filename, hostname, PID, \ timestamp, emailgroup, message) \ values (?,?,?,?,?,?,?,?) log4perl.appender.AlertDatabase.params.1 = %d{yyyy-DDD/HH:mm:ss} log4perl.appender.AlertDatabase.params.2 = %p log4perl.appender.AlertDatabase.params.3 = %F{2} log4perl.appender.AlertDatabase.params.4 = %H log4perl.appender.AlertDatabase.params.5 = %P #6 is timestamp from log call #7 is emailgroup from log call #8 is message from log call ## ## Define a filter routine to remove SDO Commands ## from the event log ## log4perl.filter.CommandFilter = sub { \ !/CMH-I:CMD/ \ }; ## ## ASIST Database Appender ## # NOTE: DBI_Buffer uses all options from Log::Log4perl::Appender::DBI log4perl.appender.ASISTDatabase = DBI_Buffer log4perl.appender.ASISTDatabase.Filter = CommandFilter log4perl.appender.ASISTDatabase.layout = Log::Log4perl::Layout::NoopLayout log4perl.appender.ASISTDatabase.warp_message = 0 log4perl.appender.ASISTDatabase.datasource = DBI:mysql:database=asistdb:host=localhost;mysql_auto_reconnect=1 log4perl.appender.ASISTDatabase.username = foo log4perl.appender.ASISTDatabase.password = bar log4perl.appender.ASISTDatabase.logbuffer = 4000 log4perl.appender.ASISTDatabase.errorappender = Logfile log4perl.appender.ASISTDatabase.errorstodatabase = 0 log4perl.appender.ASISTDatabase.sql = \ insert into events \ (date, loglevel, filename, hostname, PID, \ asisthost, timestamp, class, message) \ values (?,?,?,?,?,?,?,?,?) log4perl.appender.ASISTDatabase.params.1 = %d{yyyy-DDD/HH:mm:ss} log4perl.appender.ASISTDatabase.params.2 = %p log4perl.appender.ASISTDatabase.params.3 = %F{2} log4perl.appender.ASISTDatabase.params.4 = %H log4perl.appender.ASISTDatabase.params.5 = %P #6 is asisthost from log call #7 is timestamp from log call #8 is class from log call #9 is message from log call ## ## ## DMZ Database Appender ## # NOTE: DBI_Buffer uses all options from Log::Log4perl::Appender::DBI log4perl.appender.DMZDatabase = DBI_Buffer log4perl.appender.DMZDatabase.Filter = CommandFilter log4perl.appender.DMZDatabase.layout = Log::Log4perl::Layout::NoopLayout log4perl.appender.DMZDatabase.warp_message = 0 log4perl.appender.DMZDatabase.datasource = DBI:mysql:database=asistdb:host=remotesys;mysql_auto_reconnect=1 log4perl.appender.DMZDatabase.username = foo log4perl.appender.DMZDatabase.password = bar log4perl.appender.DMZDatabase.logbuffer = 4000 log4perl.appender.DMZDatabase.errorappender = Logfile log4perl.appender.DMZDatabase.errorstodatabase = 0 log4perl.appender.DMZDatabase.sql = \ insert into events \ (date, loglevel, filename, hostname, PID, \ asisthost, timestamp, class, message) \ values (?,?,?,?,?,?,?,?,?) log4perl.appender.DMZDatabase.params.1 = %d{yyyy-DDD/HH:mm:ss} log4perl.appender.DMZDatabase.params.2 = %p log4perl.appender.DMZDatabase.params.3 = %F{2} log4perl.appender.DMZDatabase.params.4 = %H log4perl.appender.DMZDatabase.params.5 = %P #6 is asisthost from log call #7 is timestamp from log call #8 is class from log call #9 is message from log call ## ## DB Syncronizer ## # Technically, only the forked children for event.pl and target.pl # need to be Sync'd, but we are syncing all of the modules # If performance becomes an issue, try syncing only event.pl and target.pl log4perl.appender.SyncDatabase = Log::Log4perl::Appender::Synchronized log4perl.appender.SyncDatabase.appender = Database # Random semaphore key; otherwise they clobber each other log4perl.appender.SyncDatabase.key = sub { int(rand(10000)); } -- Thanks, Rob |
From: <wzh...@gm...> - 2009-02-18 16:52:35
|
I have a script running, which can be stopped and restarted frequently. I was able to get the file rotation working until I added "log4perl.appender.RunMonitorLogFile.mode = append" to set the mode to append, so the previous script run's log file doesn't get wiped out after a restart of the script. It's not rotating anymore. What I want is: continuous logging, and log rotation at midnight.Thanks for your help! David On Tue, Feb 17, 2009 at 4:41 PM, Mike Schilli <m...@pe...> wrote: > On Tue, 17 Feb 2009, wzh...@gm... wrote: > > I'd like the main.log to rotate at midnight, and persist among >> restarts (log file not wiped out among restarts) so I used "append" >> mode here, but the rotation is not working, did I set this up wrong? >> Thanks in advance! >> > > Can you specify what exactly isn't working? > > Note that the rotation will only happen if you're writing a message. > > Also, if you're not sure if it's working correctly, use a shorter > rotation interval (e.g. every minute) to create a test case you can > verify quickly. > > -- Mike > > Mike Schilli > m...@pe... > > > Hi there, Here is my log4perl.properties file: #predefined variables >> layout_class = Log::Log4perl::Layout::PatternLayout layout_pattern >> = %d %5p %F{1} %L> %m %n layout_email_pattern = %d{yyyy-MM-dd >> HH:mm:ss} [%F{1}:%c{1}:%L] %5p> %m%n log_file_appender >> = Log::Dispatch::FileRotate >> >> #log4perl category >> log4perl.logger.main = WARN, MainLogfile, Email >> >> log4perl.appender.MainLogfile = Log::Dispatch::FileRotate >> log4perl.appender.MainLogfile.filename = main.log >> log4perl.appender.MainLogfile.mode = append >> log4perl.appender.MainLogfile.max = 5 >> log4perl.appender.MainLogfile.DatePattern = yyyy-MM-dd >> log4perl.appender.MainLogfile.TZ = PST >> log4perl.appender.MainLogfile.layout = ${layout_class} >> log4perl.appender.MainLogfile.layout.ConversionPattern = ${layout_pattern} >> >> |