Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1179

Performance issue with isDebugEnabled classic logback checking vs LOG.isDebugEnabled

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.1.7
    • logback-classic
    • None
    • Windows + JDK 1.7.0_49

    Description

      Hi,

      As i know, The debug check is done twice, once in the conditional test - then again in the debug() method. While doing this operation twice is probably trivial to the overall performance of the app. It is inefficient - and a poor use of CPU cycles. Slf4j provided “parameterized logging” which prevents string concatenation, and does the debug check only once.

      I have done performance testing with using classic log back with slf4j API. I set LOG LEVEL is ERROR.

      private static final Logger LOG = LoggerFactory.getLogger(MyClass.class);
      

      Case 1:

      if(LOG.isDebugEnabled())
      {
         LOG.debug("any message from {}", myName);
      }
      

      Case :2 without isDebugEnabled Check

       LOG.debug("any message from {}", myName);
      

      In Case 2, I found that classic logback takes time in checking DEBUG Enable.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            ervikma Ravi Kant Sharma
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: