[logback-dev] [JIRA] Commented: (LBCLASSIC-273) Status messages of StatusManager are not cleared upon call to LoggerContext.reset()

Ceki Gulcu (JIRA) noreply-jira at qos.ch
Thu Jun 9 14:14:53 CEST 2011

    [ http://jira.qos.ch/browse/LBCLASSIC-273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12028#action_12028 ] 

Ceki Gulcu commented on LBCLASSIC-273:

Hi Joern,

Retaining status messages from previous invocations of Joran may be sometimes useful. This assumption precludes your approach of resetting StatusManager's state which I must admit much simpler than what I have in mind.

Anyhow, the current behavior where status messages from previous invocations of a configurator, i.e. Joran/Gaffer, are printed is indeed confusing and needs to be corrected.  The confusing behavior occurs if you enable debug mode via the <configuration debug="true"> directive or if there were warnings or errors in a previous invocation of Joran/Gaffer.

Consequently, I think we should alter logback's behavior for those two cases (debug=true and auto-printing in case of errors) instead of clearing status messages from earlier runs of Joran/Gaffer. I think the required changes are limited to the ConfigurationAction class and the init() method of StaticLoggerBinder. Moreover, since the StaticLoggerBinder#init method is invoked at most once during the lifetime of a context, only ConfigurationAction needs to be modified.

Regarding the level field in BasicManager, AFAIK, it is used by StatusPrinter's printIfErrorsOccured() and printInCaseOfErrorsOrWarnings() methods which in turn are only used by StaticLoggerBinder#init. Thus, from a somewhat narrow point of view there is no need to reset the level field in BasicManager. Of course, from a larger API view point, the current meaning of level is unclear and rather confusing.

To solve this issue, I would start by modifying the end() method in ConfigurationAction so that it only prints status messages added after its begin() method was invoked. This could be achieved by adding a new print method to StatusPrinter. The new print() method would admit a second parameter designating the cut off point.

As mentioned earlier, just resetting the StausManager is possibly a saner approach.  Let me know what you think.

> Status messages of StatusManager are not cleared upon call to LoggerContext.reset()
> -----------------------------------------------------------------------------------
>                 Key: LBCLASSIC-273
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-273
>             Project: logback-classic
>          Issue Type: Bug
>    Affects Versions: 0.9.28
>            Reporter: Joern Huxhorn
>            Assignee: Logback dev list
> See https://github.com/ceki/logback/pull/15

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list