On Wed, 4 Jul 2012, Meir Guttman wrote:
Well, I found at least one use for the $logger->log() method: dynamic level logging.
Hi Meir, that's an interesting use case, thanks for reporting it. I've changed the documentation accordingly: https://github.com/mschilli/log4perl/commit/b60c85acb482095a5d1939c2a25e64653f3c3624 -- -- Mike Mike Schilli m...@perlmeister.com
I have though an issue with one passage in the documentation. In the CPAN page Log::Log4perl (Ver. 1.37) (http://search.cpan.org/~mschilli/Log-Log4perl-1.37/lib/Log/Log4perl.pm) one can read the following: Instead of calling the methods $logger->trace("..."); # Log a trace message ... (other variants deleted) you could also call the log() method with the appropriate level using the constants defined in Log::Log4perl::Level: use Log::Log4perl::Level; $logger->log($TRACE, "..."); ... (other variants deleted) But *** nobody does that, really ***. (my enhancement - MG) Neither does anyone need more logging levels than these predefined ones. If you think you do, I would suggest you look into steering your logging behavior via the category mechanism. Well, I found at least one use for the $logger->log() method: dynamic level logging. Take for example a "system()" call. It can return a number of exit codes by issuing something like «exit(0x2C);» command. I find it very convenient to segregate on the basis of the return code what logging level to assign to the log message upon returning: my %exit_level = ( 0 => $INFO, 1 => $WARN, 2 => $WARN, 4 => $ERROR, 0xFF => $FATAL, ); My %message = ( 0 => "Message 1", 1 => "..." ... ); my $result = system ('perl', 'my_script.pl, @args) >>= 8; $logger->log($exit_level{$result}, $message{$result}); So, I would recommend a change in the doc showing such an example. Meir ------------------------------------------------------------------------------ Live Security Virtual ConferenceExclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel