Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1813

Provide shorter and more intuitive way to switch on Log4j internal debug logging

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8
    • Fix Version/s: 2.9.0
    • Component/s: Configurators
    • Labels:
      None

      Description

      People find it difficult to troubleshoot Log4j 2 configuration issues. Many people don't know what the "status" attribute is for at the beginning of the configuration:

      <Configuration status="warn"> ...
      

      In addition, the above setting does not take effect until the configuration file is found. If users have trouble making Log4j 2 find their configuration file, the above does not help.

      In such cases, users can enable internal status logging by setting system property org.apache.logging.log4j.simplelog.StatusLogger.level to TRACE.

      This is problematic because:

      • It is not well-known (documented in the FAQ and on the configuration page but many people don't know about this feature)
      • The name is a bit... lengthy
      • Apparently people don't intuitively grasp that "status logging" means the internal log4j 2 debug logging facility.
      • It is confusing that there are two phases (before config file found and after), and the status logger level can be different and needs to be specified separately

      I propose we add a short, intuitive system property that results in all internal Log4j 2 status logging to be printed to the console. When set, this property should even override the configuration status attribute in my opinion.

      Something like -Dlog4j2.debug (without even requiring a value) would be good, but I'm open to any suggestions.

        Activity

        Hide
        ralphgoers Ralph Goers added a comment -

        If I am not mistaken, the change Matt just implemented should allow a shorter name for the property. I think adding yet another property that modifies the level makes it more confusing, not less. If this property is added the StatusLogger property should be removed from the documentation in my opinion.

        Show
        ralphgoers Ralph Goers added a comment - If I am not mistaken, the change Matt just implemented should allow a shorter name for the property. I think adding yet another property that modifies the level makes it more confusing, not less. If this property is added the StatusLogger property should be removed from the documentation in my opinion.
        Hide
        jvz Matt Sicker added a comment -

        The simplified property system (which isn't merged yet btw) would support that long name as one of the following:

        • log4j2.simplelog.StatusLogger.level
        • log4j2.simplelogStatusLoggerLevel
        • and many other combinations, yet the shortest possible property name for this would be:
        • simplelogStatusLoggerLevel
        • ...which is still pretty long.
        Show
        jvz Matt Sicker added a comment - The simplified property system (which isn't merged yet btw) would support that long name as one of the following: log4j2.simplelog.StatusLogger.level log4j2.simplelogStatusLoggerLevel and many other combinations, yet the shortest possible property name for this would be: simplelogStatusLoggerLevel ...which is still pretty long.
        Hide
        remkop@yahoo.com Remko Popma added a comment -

        That is certainly an improvement and I like the initiative.

        I would like to give the -Dlog4j2.debug switch special treatment: note that no value is required, just specifying the property is the equivalent of -Dlog4j2.simplelog.StatusLogger.level=TRACE, plus it should persist even if the configuration file has a different value in its status attribute.

        Show
        remkop@yahoo.com Remko Popma added a comment - That is certainly an improvement and I like the initiative. I would like to give the -Dlog4j2.debug switch special treatment: note that no value is required, just specifying the property is the equivalent of -Dlog4j2.simplelog.StatusLogger.level=TRACE , plus it should persist even if the configuration file has a different value in its status attribute.
        Hide
        jvz Matt Sicker added a comment -

        That reminds me; I'd like to point out that LoggerContextRule in log4j-core:test interprets the system property "EBUG" as a debug switch (-DEBUG). That class should be updated to support this proposed property as well for completeness sake.

        Show
        jvz Matt Sicker added a comment - That reminds me; I'd like to point out that LoggerContextRule in log4j-core:test interprets the system property "EBUG" as a debug switch ( -DEBUG ). That class should be updated to support this proposed property as well for completeness sake.
        Hide
        garydgregory Gary Gregory added a comment -

        Yeah, the "EBUG" is not pretty.

        I had a question about this topic recently from a co-worker who was baffled by our crazy long property name instead of a Log4j 1-like "log4j2.debug"

        Show
        garydgregory Gary Gregory added a comment - Yeah, the "EBUG" is not pretty. I had a question about this topic recently from a co-worker who was baffled by our crazy long property name instead of a Log4j 1-like "log4j2.debug"
        Hide
        jvz Matt Sicker added a comment -

        We'd have to add another method in PropertiesUtil like hasProperty() to support this if it doesn't need a value.

        Show
        jvz Matt Sicker added a comment - We'd have to add another method in PropertiesUtil like hasProperty() to support this if it doesn't need a value.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 785892d6a5c89350e06d3bc802a86d8e75f29337 in logging-log4j2's branch refs/heads/master from rpopma
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=785892d ]

        LOG4J2-1813 Log4j2 will now print all internal logging to the console if system property `log4j2.debug` is defined with any value (or no value).

        Show
        jira-bot ASF subversion and git services added a comment - Commit 785892d6a5c89350e06d3bc802a86d8e75f29337 in logging-log4j2's branch refs/heads/master from rpopma [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=785892d ] LOG4J2-1813 Log4j2 will now print all internal logging to the console if system property `log4j2.debug` is defined with any value (or no value).
        Hide
        remkop@yahoo.com Remko Popma added a comment -

        Fixed in master.

        Show
        remkop@yahoo.com Remko Popma added a comment - Fixed in master.
        Hide
        garydgregory Gary Gregory added a comment -

        I plan on change this implementation such that -Dlog4j2.debug=false does what you'd expect...

        Show
        garydgregory Gary Gregory added a comment - I plan on change this implementation such that -Dlog4j2.debug=false does what you'd expect...
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 0c80e2a83c3e6d0bfc16d72ccc53a6fd3fdcc02a in logging-log4j2's branch refs/heads/master from Gary Gregory
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=0c80e2a ]

        LOG4J2-1813
        Provide shorter and more intuitive way to switch on Log4j internal debug
        logging. Refactor current system property query into a private method to
        avoid duplication.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 0c80e2a83c3e6d0bfc16d72ccc53a6fd3fdcc02a in logging-log4j2's branch refs/heads/master from Gary Gregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=0c80e2a ] LOG4J2-1813 Provide shorter and more intuitive way to switch on Log4j internal debug logging. Refactor current system property query into a private method to avoid duplication.
        Hide
        garydgregory Gary Gregory added a comment -

        Which is:

        • -Dlog4j2.debug means DEBUG is ON
        • -Dlog4j2.debug=true means DEBUG is ON
        • -Dlog4j2.debug=false means DEBUG is OFF
        • -Dlog4j2.debug=flibberMeWidget means DEBUG is OFF
        Show
        garydgregory Gary Gregory added a comment - Which is: -Dlog4j2.debug means DEBUG is ON -Dlog4j2.debug=true means DEBUG is ON -Dlog4j2.debug=false means DEBUG is OFF -Dlog4j2.debug=flibberMeWidget means DEBUG is OFF
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit c536ea92f586d920920e2837a2bb227f8343b339 in logging-log4j2's branch refs/heads/master from Gary Gregory
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=c536ea9 ]

        LOG4J2-1813
        Provide shorter and more intuitive way to switch on Log4j internal debug
        logging. -Dlog4j2.debug means DEBUG is ON
        -Dlog4j2.debug=true means DEBUG is ON
        -Dlog4j2.debug=false means DEBUG is OFF
        -Dlog4j2.debug=flibberMeWidget means DEBUG is OFF

        Show
        jira-bot ASF subversion and git services added a comment - Commit c536ea92f586d920920e2837a2bb227f8343b339 in logging-log4j2's branch refs/heads/master from Gary Gregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=c536ea9 ] LOG4J2-1813 Provide shorter and more intuitive way to switch on Log4j internal debug logging. -Dlog4j2.debug means DEBUG is ON -Dlog4j2.debug=true means DEBUG is ON -Dlog4j2.debug=false means DEBUG is OFF -Dlog4j2.debug=flibberMeWidget means DEBUG is OFF
        Hide
        garydgregory Gary Gregory added a comment -

        Done.

        Show
        garydgregory Gary Gregory added a comment - Done.

          People

          • Assignee:
            remkop@yahoo.com Remko Popma
            Reporter:
            remkop@yahoo.com Remko Popma
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development