[
https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028149#comment-16028149
]
Ajitha commented on LOG4J2-1921:
--------------------------------
@Ralph: Your information helps a bit. I had one problem in the integration. The
log4j-api-2.8.3 has some problem with Android because Android does not support
Java9 yet(expected in mere future) and I think log4j-api-2.8.3 has classes
compiled in that version of java like ClassNamePredicate.class.
So I took 2.8.2 which was compatible and then took log4j-core-2.8.3 . Hence i
think there is some problem.Can you give me some additional pointers to
integrate with android?
And one small question. Do you have any sample application for Android with
log4j application that I can refer to?
> Getting ClassCastException while getting LoggerContext
> ------------------------------------------------------
>
> Key: LOG4J2-1921
> URL: https://issues.apache.org/jira/browse/LOG4J2-1921
> Project: Log4j 2
> Issue Type: Bug
> Components: Configurators
> Affects Versions: 2.8.2
> Environment: Android
> Reporter: Ajitha
> Priority: Blocker
>
> Hi,
> I integrated the log4j with my Android application and did the initial
> config. It works fine. I have a menu item in "Settings" screen where I can
> change the log levels in my application. So, After I change the
> configuration, I need to update the loggers. So I am using following logic.
> {code:java}
> LoggerContext ctx = LoggerContext.getContext()
> Configuration config = ctx.getConfiguration();
> LoggerConfig loggerConfig =
> config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
> loggerConfig.setLevel(myLogLevel);
> ctx.updateLoggers();
> {code}
> While getting the logger context, I am getting a ClassCastException.
> 05-26 22:33:21.011 E/AndroidRuntime( 9642): Caused by:
> java.lang.ClassCastException:
> org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to
> org.apache.logging.log4j.core.LoggerContext
> 05-26 22:33:21.011 E/AndroidRuntime( 9642): at
> org.apache.logging.log4j.core.LoggerContext.getContext(LoggerContext.java:190)
> 05-26 22:33:21.011 E/AndroidRuntime( 9642): at
> org.apache.logging.log4j.core.config.Configurator.setRootLevel(Configurator.java:323)
> Please help here.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)