Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-37814 Migrating from log4j 1 to log4j 2
  3. SPARK-37746

log4j2-defaults.properties is not working since log4j 2 is always initialized by default

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.3.0
    • 3.3.0
    • Spark Core
    • None

    Description

      the code used to check initialization is shown below.

            val log4j2Initialized = !LogManager.getRootLogger
              .asInstanceOf[org.apache.logging.log4j.core.Logger].getAppenders.isEmpty

      That works for log4j. However, log4j2 provides a default configuration so there is always a appender (ConsoleAppender) with error level.

       

      reference from https://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration

      Log4j will provide a default configuration if it cannot locate a configuration file. The default configuration, provided in the DefaultConfiguration class, will set up:

      • A ConsoleAppender attached to the root logger.
      • A PatternLayout set to the pattern "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" attached to the ConsoleAppender

      Note that by default Log4j assigns the root logger to Level.ERROR.

       

       

       

      Attachments

        Issue Links

          Activity

            People

              chia7712 Chia-Ping Tsai
              chia7712 Chia-Ping Tsai
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: