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

ServiceConfigurationError in Tomcat when Log4j is used as the logging implementation

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.10.0
    • Fix Version/s: 2.11.2
    • Component/s: Core
    • Labels:
      None
    • Environment:

      Tomcat 8.5.24, JDK 1.8.

      Description

      I do not know, if it matters: The same webapp (with different configurations) is deployed multiple times in the same Tomcat. This results in an error directly at startup:

      ```
      Caused by: java.util.ServiceConfigurationError: org.apache.logging.log4j.util.PropertySource: Provider org.apache.logging.log4j.util.EnvironmentPropertySource not a subtype
      at java.util.ServiceLoader.fail(ServiceLoader.java:239)
      at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
      at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
      at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
      at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
      at org.apache.logging.log4j.util.PropertiesUtil$Environment.<init>(PropertiesUtil.java:319)
      at org.apache.logging.log4j.util.PropertiesUtil$Environment.<init>(PropertiesUtil.java:310)
      at org.apache.logging.log4j.util.PropertiesUtil.<init>(PropertiesUtil.java:59)
      at org.apache.logging.log4j.core.appender.ConsoleAppender$Target.getCharset(ConsoleAppender.java:92)
      at org.apache.logging.log4j.core.appender.ConsoleAppender$Target$1.getDefaultCharset(ConsoleAppender.java:76)
      at org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:225)
      at org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:192)
      at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)
      at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
      at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617)
      at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
      at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
      at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
      at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:122)
      at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
      at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
      at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
      at org.slf4j.bridge.SLF4JBridgeHandler.getSLF4JLogger(SLF4JBridgeHandler.java:202)
      at org.slf4j.bridge.SLF4JBridgeHandler.publish(SLF4JBridgeHandler.java:293)
      at java.util.logging.Logger.log(Logger.java:738)
      at java.util.logging.Logger.doLog(Logger.java:765)
      at java.util.logging.Logger.logp(Logger.java:931)
      at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:180)
      at org.apache.juli.logging.DirectJDKLog.info(DirectJDKLog.java:123)
      at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:264)
      at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104)
      at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)```

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rgoers Ralph Goers
                Reporter:
                markus_heiden Markus Heiden
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: