[ 
https://issues.apache.org/jira/browse/LOG4J2-460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13845987#comment-13845987
 ] 

Remko Popma commented on LOG4J2-460:
------------------------------------

This looks like a classpath issue. If both the core and the api jars are on the 
classpath, the LogManager class (which lives in the api jar) will load 
implementation classes from the core jar.
If the LogManager returns a 
{{org.apache.logging.log4j.simple.SimpleLoggerContext}} instance it means that 
it has been unable to find the core implementation on the classpath.

Specifically, it has been unable to find the 
{{/META-INF/log4j-provider.properties}} file that is in the core jar.

Can you print the value of system property {{java.class.path}} to the console 
from your application to verify that the core jar is on the classpath?

> java.lang.ClassCastException: 
> org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to 
> org.apache.logging.log4j.core.LoggerContext
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-460
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-460
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.0-beta9
>         Environment: Android
>            Reporter: Gaurav Kapoor
>            Priority: Blocker
>
> I'm trying to integrate Log4j2 in Android but getting the following error 
> message:
> java.lang.ClassCastException: 
> org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to 
> org.apache.logging.log4j.core.LoggerContext
> Code:
> {code}
> import org.apache.logging.log4j.Level;
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.core.Logger;
> import org.apache.logging.log4j.core.LoggerContext;
> import org.apache.logging.log4j.core.appender.SyslogAppender;
>   LoggerContext context = (LoggerContext) LogManager.getContext();
>   Logger root = context.getLogger("MainActivity");
>   SyslogAppender appender = obtainAppender();
>   if (!appender.isStarted()) 
>     appender.start();
>   root.addAppender(appender);
>   root.setAdditive(false);
>   root.setLevel(Level.DEBUG);
>   root.debug("This is a test message");
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.4#6159)

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

Reply via email to