logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Sutherland (JIRA)" <j...@apache.org>
Subject [jira] [Reopened] (LOG4J2-862) Misleading error message "Log4j2 could not find a logging implementation. Please add log4j-core to the classpath."
Date Mon, 29 Sep 2014 04:34:33 GMT

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

Michael Sutherland reopened LOG4J2-862:
---------------------------------------

I've tried building from trunk and I'd say this is still a problem. I think it's due to ProviderUtil.findClassLoader
going directly to LoaderUtil.getThreadContextClassLoader(). It means all the code in LoaderUtil
that checks for the "IGNORE_TCCL_PROPERTY" is skipped and Thread.currentThread().getContextClassLoader()
is exectuted despite the system properties. 

If i replace the line {{if (cl != null){}} with {{if (cl != null && !"true".equals(System.getProperty(IGNORE_TCCL_PROPERTY)))
{}} log4j works as I'd expect but it doesn't fit the architecture of having PropertiesUtil

> Misleading error message "Log4j2 could not find a logging implementation. Please add
log4j-core to the classpath."
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-862
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-862
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators
>    Affects Versions: 2.0.2
>            Reporter: Michael Sutherland
>            Assignee: Matt Sicker
>             Fix For: 2.1
>
>
> In the code out put I see
> "ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core
to the classpath. Using SimpleLogger to log to the console..." followed by "java.lang.ClassCastException:
org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext"
which means core must be on the class path as otherwise you couldn't get that class cast execption.
At which point the application using Log4j2 fails to start. 
> The underlying problem is org.apache.logging.log4j.LogManager assuming if org.apache.logging.log4j.util.ProviderUtil
returns false for hasProviders it is because core is not on the classpath. In practice I've
found that hasProviders can return false because ProviderUtil is using a different Classloader
than the rest of the application. It cannot find the "META-INF/log4j-provider.properties"
resource but it is on the class path.
> I think there is a problem with the logic of how the classloaders are chosen but I don't
understand what Log4j is trying to do here, however I am sure the error message is confusing
and misleading



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message