You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by "Ivan Habunek (JIRA)" <ji...@apache.org> on 2012/10/07 10:33:02 UTC

[jira] [Commented] (LOG4PHP-188) rootLogger logs although level isn't reached

    [ https://issues.apache.org/jira/browse/LOG4PHP-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13471174#comment-13471174 ] 

Ivan Habunek commented on LOG4PHP-188:
--------------------------------------

Thanks for reporting this guys. It is indeed a problem, the event should always be forwarded upstream, but only logged if enabled.

Michael, your solution manages that, but has a small problem: a LoggerLoggingEvent object is created each time, regardless of the Logger level and additivity. This degrades performance slightly, and I'd like to avoid that.

Instead of moving the isEnabled check to callAppenders(), I moved upstream forwarding to log() method. A new method logEvent() enables already created logging events to be forwarded upstream. This solution is a bit more complicated, but it ensures that a LoggerLoggingEvent object is not be constructed until the moment it's determined that it will be logged.

Have a look at the code, it's in the repo. Try it out, please and report any unexpected behaviour.
                
> rootLogger logs although level isn't reached
> --------------------------------------------
>
>                 Key: LOG4PHP-188
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-188
>             Project: Log4php
>          Issue Type: Question
>          Components: Code
>    Affects Versions: 2.2.1
>         Environment: Windows Server 2008 R2, IIS 7
>            Reporter: Florian Platzer
>            Priority: Minor
>             Fix For: 2.3.0
>
>         Attachments: log4php.patch, test.php
>
>
> I downloaded the current version of log4php and used an existing configuration:
> rootLogger (level = FATAL, appender = echo)
> customLog (level = DEBUG, appender = dailyfile)
> When i log to customLog with DEBUG level, i also get the message printed on screen:
> Logger::getLogger('customLog')->debug('test');
> When I change rootLogger's appender to dailyfile, the message is logged twice in the log file.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira