[ 
https://issues.apache.org/jira/browse/LOG4J2-2956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ralph Goers updated LOG4J2-2956:
--------------------------------
    Description: 
Assumptions:
 # Application is a Spring Boot app.
 # {{It is configured to use spring-boot-starter-log4j2}}

{{There is a log4j2.cfg.xml provided through logging.config property and it is 
working fine. It contains following part:}}

 
{noformat}
<DynamicThresholdFilter key="X-Log-Level" onMatch="ACCEPT" 
onMismatch="NEUTRAL">   
 <DefaultThreshold>INFO</DefaultThreshold>
 <KeyValuePair key="DEBUG" value="DEBUG" />
 <KeyValuePair key="TRACE" value="TRACE" />
</DynamicThresholdFilter>{noformat}
{{However when dependency log4j-spring-cloud-config-client is added application 
does not start with following exception:}}
{noformat}
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize 
class org.apache.logging.log4j.core.impl.ContextDataFactoryException in thread 
"main" java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.logging.log4j.core.impl.ContextDataFactory 
at 
org.apache.logging.log4j.core.impl.ThreadContextDataInjector$ForDefaultThreadContextMap.rawContextData(ThreadContextDataInjector.java:137)
 
at 
org.apache.logging.log4j.core.filter.DynamicThresholdFilter.currentContextData(DynamicThresholdFilter.java:162)
 
at 
org.apache.logging.log4j.core.filter.DynamicThresholdFilter.filter(DynamicThresholdFilter.java:152)
 at org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Logger.java:609) 
at org.apache.logging.log4j.core.Logger.isEnabled(Logger.java:258) at 
org.apache.logging.log4j.spi.AbstractLogger.isEnabled(AbstractLogger.java:1513) 
at 
org.apache.commons.logging.LogAdapter$Log4jLog.isErrorEnabled(LogAdapter.java:175)
 at 
org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:836)
 
at 
org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:812)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) 
at 
pl.frati.moray.configserver.ConfigServerApplication.main(ConfigServerApplication.java:12)

{noformat}
First of all I have no idea what is missing. Without mentioned dependency 
application startup is correct. Also, removing DynamicThresholdFilter solves 
the problem as well.

Second of all it seems that exception message is somewhat broken, because it 
does not say anything about what class is missing. I've tried to debug this, 
but class ContextDataFactory is pretty hard to debug. Fix in exception message 
should ease the hunt.

 

  was:
Assumptions:
 # Application is a Spring Boot app.
 # {{It is configured to use spring-boot-starter-log4j2}}

{{There is a log4j2.cfg.xml provided through logging.config property and it is 
working fine. It contains following part:}}

 
{noformat}
<DynamicThresholdFilter key="X-Log-Level" onMatch="ACCEPT" 
onMismatch="NEUTRAL">   
 <DefaultThreshold>INFO</DefaultThreshold>
 <KeyValuePair key="DEBUG" value="DEBUG" />
 <KeyValuePair key="TRACE" value="TRACE" />
</DynamicThresholdFilter>{noformat}
{{However when dependency log4j-spring-cloud-config-client is added application 
does not start with following exception:}}
{noformat}
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize 
class org.apache.logging.log4j.core.impl.ContextDataFactoryException in thread 
"main" java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.logging.log4j.core.impl.ContextDataFactory at 
org.apache.logging.log4j.core.impl.ThreadContextDataInjector$ForDefaultThreadContextMap.rawContextData(ThreadContextDataInjector.java:137)
 at 
org.apache.logging.log4j.core.filter.DynamicThresholdFilter.currentContextData(DynamicThresholdFilter.java:162)
 at 
org.apache.logging.log4j.core.filter.DynamicThresholdFilter.filter(DynamicThresholdFilter.java:152)
 at org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Logger.java:609) 
at org.apache.logging.log4j.core.Logger.isEnabled(Logger.java:258) at 
org.apache.logging.log4j.spi.AbstractLogger.isEnabled(AbstractLogger.java:1513) 
at 
org.apache.commons.logging.LogAdapter$Log4jLog.isErrorEnabled(LogAdapter.java:175)
 at 
org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:836)
 at 
org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:812)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) 
at 
pl.frati.moray.configserver.ConfigServerApplication.main(ConfigServerApplication.java:12)

{noformat}
First of all I have no idea what is missing. Without mentioned dependency 
application startup is correct. Also, removing DynamicThresholdFilter solves 
the problem as well.

Second of all it seems that exception message is somewhat broken, because it 
does not say anything about what class is missing. I've tried to debug this, 
but class ContextDataFactory is pretty hard to debug. Fix in exception message 
should ease the hunt.

 


> Using log4j-spring-cloud-config-client and DynamicThresholdFilter cause Could 
> not initialize class 
> org.apache.logging.log4j.core.impl.ContextDataFactoryException
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2956
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2956
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Spring
>    Affects Versions: 2.13.3
>            Reporter: Rafał Figas
>            Priority: Major
>
> Assumptions:
>  # Application is a Spring Boot app.
>  # {{It is configured to use spring-boot-starter-log4j2}}
> {{There is a log4j2.cfg.xml provided through logging.config property and it 
> is working fine. It contains following part:}}
>  
> {noformat}
> <DynamicThresholdFilter key="X-Log-Level" onMatch="ACCEPT" 
> onMismatch="NEUTRAL">   
>  <DefaultThreshold>INFO</DefaultThreshold>
>  <KeyValuePair key="DEBUG" value="DEBUG" />
>  <KeyValuePair key="TRACE" value="TRACE" />
> </DynamicThresholdFilter>{noformat}
> {{However when dependency log4j-spring-cloud-config-client is added 
> application does not start with following exception:}}
> {noformat}
> Exception in thread "main" java.lang.NoClassDefFoundError: Could not 
> initialize class 
> org.apache.logging.log4j.core.impl.ContextDataFactoryException in thread 
> "main" java.lang.NoClassDefFoundError: Could not initialize class 
> org.apache.logging.log4j.core.impl.ContextDataFactory 
> at 
> org.apache.logging.log4j.core.impl.ThreadContextDataInjector$ForDefaultThreadContextMap.rawContextData(ThreadContextDataInjector.java:137)
>  
> at 
> org.apache.logging.log4j.core.filter.DynamicThresholdFilter.currentContextData(DynamicThresholdFilter.java:162)
>  
> at 
> org.apache.logging.log4j.core.filter.DynamicThresholdFilter.filter(DynamicThresholdFilter.java:152)
>  at 
> org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Logger.java:609) 
> at org.apache.logging.log4j.core.Logger.isEnabled(Logger.java:258) at 
> org.apache.logging.log4j.spi.AbstractLogger.isEnabled(AbstractLogger.java:1513)
>  
> at 
> org.apache.commons.logging.LogAdapter$Log4jLog.isErrorEnabled(LogAdapter.java:175)
>  at 
> org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:836)
>  
> at 
> org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:812)
>  at 
> org.springframework.boot.SpringApplication.run(SpringApplication.java:325) 
> at 
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) 
> at 
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) 
> at 
> pl.frati.moray.configserver.ConfigServerApplication.main(ConfigServerApplication.java:12)
> {noformat}
> First of all I have no idea what is missing. Without mentioned dependency 
> application startup is correct. Also, removing DynamicThresholdFilter solves 
> the problem as well.
> Second of all it seems that exception message is somewhat broken, because it 
> does not say anything about what class is missing. I've tried to debug this, 
> but class ContextDataFactory is pretty hard to debug. Fix in exception 
> message should ease the hunt.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to