Discussion:
[jira] [Created] (LOG4J2-1921) Getting ClassCastException while getting LoggerContext
Ajitha (JIRA)
2017-05-26 12:39:04 UTC
Permalink
Ajitha created LOG4J2-1921:
------------------------------

Summary: 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.

LoggerContext ctx = LoggerContext.getContext()
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(myLogLevel);
ctx.updateLoggers();

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)
Gary Gregory (JIRA)
2017-05-27 01:46:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory updated LOG4J2-1921:
---------------------------------
Description:
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.

was:
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.

LoggerContext ctx = LoggerContext.getContext()
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(myLogLevel);
ctx.updateLoggers();

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.
Post by Ajitha (JIRA)
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)
Gary Gregory (JIRA)
2017-05-27 01:48:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16027117#comment-16027117 ]

Gary Gregory commented on LOG4J2-1921:
--------------------------------------

Can you try one of the {{org.apache.logging.log4j.core.config.Configurator}} {{setLevel()}} method?
Post by Ajitha (JIRA)
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)
Ajitha (JIRA)
2017-05-29 04:27:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028029#comment-16028029 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

@Greg: Same crash is being observed.

Caused by: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
Post by Ajitha (JIRA)
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)
Ajitha (JIRA)
2017-05-29 05:08:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028029#comment-16028029 ]

Ajitha edited comment on LOG4J2-1921 at 5/29/17 5:07 AM:
---------------------------------------------------------

@Greg: Same crash is being observed with:

Configurator.setLevel(LogManager.ROOT_LOGGER_NAME, loglvl);

Caused by: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext


was (Author: ajitha):
@Greg: Same crash is being observed.

Caused by: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
Post by Ajitha (JIRA)
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)
Ralph Goers (JIRA)
2017-05-29 06:02:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028065#comment-16028065 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

This does not look like a complete stack trace. Can you please provide a stack trace that includes all the Log4j stack elements?
Post by Ajitha (JIRA)
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)
Ajitha (JIRA)
2017-05-29 06:28:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028072#comment-16028072 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

I hope this is ok::

05-30 11:54:54.806 E/AndroidRuntime( 4642): Caused by: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
05-30 11:54:54.806 E/AndroidRuntime( 4642): at org.apache.logging.log4j.core.LoggerContext.getContext(LoggerContext.java:190)
05-30 11:54:54.806 E/AndroidRuntime( 4642): at org.apache.logging.log4j.core.config.Configurator.setLevel(Configurator.java:291)

Since we are using this in a enterprise application officially, I am bound not to give complete traces further... :-( I hope this is sufficient.
Post by Ajitha (JIRA)
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)
Ralph Goers (JIRA)
2017-05-29 07:24:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028089#comment-16028089 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

OK, I guess I understand what you are doing. Unfortunately, this doesn't help diagnose the problem. The issue here is that you are probably seeing a message saying it cannot find the logging implementation. When that happens it uses SimpleLogger and the log4j-core Configurator cannot do anything with that implementation. I would suggest you add status="debug" to the configuration element in your log4j2.xml and supply the output of that.
Post by Ajitha (JIRA)
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)
Ajitha (JIRA)
2017-05-29 08:52:04 UTC
Permalink
[ 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?
Post by Ajitha (JIRA)
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)
Matt Sicker (JIRA)
2017-05-29 15:23:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028460#comment-16028460 ]

Matt Sicker commented on LOG4J2-1921:
-------------------------------------

I don't know much about Android other than the fact that it's missing a lot of standard JDK classes. However, the symptoms you're describing sound like while you're compiling fine against log4j-core, it doesn't appear to be packaged in your application or there is an initialization error that should output a status log message indicating so.
Post by Ajitha (JIRA)
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)
Ralph Goers (JIRA)
2017-05-29 16:06:05 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028489#comment-16028489 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

I guess you are saying you have to compile the log4j code, which makes sense. We should be able to modify the build to not compile the Java 9 stuff if Java 9 isn't present (or if the target is Android).

I don't know of anyone who has used Log4j on Android. I was under the impression that Andriod made it difficult to use a third party logging framework and you were stuck with java.util.logging.

Do you have the debug output from Log4j?
Post by Ajitha (JIRA)
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)
Ajitha (JIRA)
2017-05-29 17:39:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028535#comment-16028535 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

@Ralph et all :

1) Android does not support java 9 yet. So I m not able to use the jar file. It wil take another few months for the support to be added.

2) since the api jar file is not compatible, I was not able to use it. So I thought of using 2.8.2 version of jar for log4j api and 2.8.3 version of jar for log4j core. This is where I got the class cast exception. I guess log4j does not allow incompatible core and api jars.

I m working from India. So tomorrow during my day, I shall try taking the source code of 2.8.3 api and 2.8.3 core and try compiling it from Android studio directly.

I will get back to you in this thread in case of issues.

Usually we - Android developers used to take the links from maven repo and put it in gradle . Now we will take the source from apache repo and try building it with the Java compiler that comes with Android SDK.

If there is any modifications that I need to do for avoiding java 9 classes let me know.
Post by Ajitha (JIRA)
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)
Mikael Ståldal (JIRA)
2017-05-29 18:14:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028539#comment-16028539 ]

Mikael Ståldal commented on LOG4J2-1921:
----------------------------------------

Can it be so that ProGuard is removing some classes from log4j-core which are needed?

Can you try to disable ProGuard, or configure it to keep everything in {{org.apache.logging.log4j.*}}?
Post by Ajitha (JIRA)
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)
Mikael Ståldal (JIRA)
2017-05-29 18:18:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028540#comment-16028540 ]

Mikael Ståldal commented on LOG4J2-1921:
----------------------------------------

Android actually has it's own logging "framework": https://developer.android.com/reference/android/util/Log.html
Post by Ajitha (JIRA)
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)
Ajitha (JIRA)
2017-05-29 23:46:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16028667#comment-16028667 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

I have not enabled proguard.

Ya am aware of Androids log class. I will check build and update this ticket.
Post by Ajitha (JIRA)
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)
Mikael Ståldal (JIRA)
2017-07-05 19:55:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikael Ståldal updated LOG4J2-1921:
-----------------------------------
Labels: Andriod (was: )
Post by Ajitha (JIRA)
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
Labels: Andriod
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.4.14#64029)
Mikael Ståldal (JIRA)
2017-07-05 20:00:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16075316#comment-16075316 ]

Mikael Ståldal commented on LOG4J2-1921:
----------------------------------------

Is this a duplicate of https://issues.apache.org/jira/browse/LOG4J2-461 ?
Post by Ajitha (JIRA)
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
Labels: Andriod
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.4.14#64029)
Mikael Ståldal (JIRA)
2017-07-05 20:03:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikael Ståldal updated LOG4J2-1921:
-----------------------------------
Labels: Android (was: Andriod)
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 07:52:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076119#comment-16076119 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Yes it is exactly https://issues.apache.org/jira/browse/LOG4J2-460.
In Android, we refer repositories directly from maven. https://mvnrepository.com/artifact/org.apache.logging.log4j
The issue "https://issues.apache.org/jira/browse/LOG4J2-1920" was fixed in 2.8.3 and not yet deployed in maven. I took 2.8.3 from apache snapshot. But when I take from Apache snapshot, it is not properly linked with Android. Because of that I suspect this issue to occur.
So, if you deploy the fix for "LOG4J2-1920" in maven repository, I would be able to retest and close this issue. :( I am helpless.
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 07:53:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076119#comment-16076119 ]

Ajitha edited comment on LOG4J2-1921 at 7/6/17 7:52 AM:
--------------------------------------------------------

Yes it is exactly 460 rather than 461...

https://issues.apache.org/jira/browse/LOG4J2-460.
In Android, we refer repositories directly from maven. https://mvnrepository.com/artifact/org.apache.logging.log4j
The issue "https://issues.apache.org/jira/browse/LOG4J2-1920" was fixed in 2.8.3 and not yet deployed in maven. I took 2.8.3 from apache snapshot. But when I take from Apache snapshot, it is not properly linked with Android. Because of that I suspect this issue to occur.
So, if you deploy the fix for "LOG4J2-1920" in maven repository, I would be able to retest and close this issue. :( I am helpless.


was (Author: ajitha):
Yes it is exactly https://issues.apache.org/jira/browse/LOG4J2-460.
In Android, we refer repositories directly from maven. https://mvnrepository.com/artifact/org.apache.logging.log4j
The issue "https://issues.apache.org/jira/browse/LOG4J2-1920" was fixed in 2.8.3 and not yet deployed in maven. I took 2.8.3 from apache snapshot. But when I take from Apache snapshot, it is not properly linked with Android. Because of that I suspect this issue to occur.
So, if you deploy the fix for "LOG4J2-1920" in maven repository, I would be able to retest and close this issue. :( I am helpless.
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 07:55:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076119#comment-16076119 ]

Ajitha edited comment on LOG4J2-1921 at 7/6/17 7:54 AM:
--------------------------------------------------------

Yes it is exactly 460 rather than 461...
https://issues.apache.org/jira/browse/LOG4J2-460.
In Android, we refer repositories directly from maven. https://mvnrepository.com/artifact/org.apache.logging.log4j
The issue "https://issues.apache.org/jira/browse/LOG4J2-1920" was fixed in 2.8.3 and not yet deployed in maven. I took 2.8.3 from apache snapshot. But when I take from Apache snapshot, it is not properly linked with Android and few cases are failing. Because of that I suspect this issue to occur. Initialisation was successful, but getting logger context is crashing. I closed bug 1920 as init was fine.
So, if you deploy the fix for "LOG4J2-1920" in maven repository, I would be able to retest and close this issue. :( I am helpless.


was (Author: ajitha):
Yes it is exactly 460 rather than 461...

https://issues.apache.org/jira/browse/LOG4J2-460.
In Android, we refer repositories directly from maven. https://mvnrepository.com/artifact/org.apache.logging.log4j
The issue "https://issues.apache.org/jira/browse/LOG4J2-1920" was fixed in 2.8.3 and not yet deployed in maven. I took 2.8.3 from apache snapshot. But when I take from Apache snapshot, it is not properly linked with Android. Because of that I suspect this issue to occur.
So, if you deploy the fix for "LOG4J2-1920" in maven repository, I would be able to retest and close this issue. :( I am helpless.
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
Labels: Android
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.4.14#64029)
Gary Gregory (JIRA)
2017-07-06 08:00:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076125#comment-16076125 ]

Gary Gregory commented on LOG4J2-1921:
--------------------------------------

Note that the current SNAPSHOT version was updated to 2.9-SNAPSHOT since our next release will be 2.9.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 08:12:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076138#comment-16076138 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Thanks. But when can I expect it to get updated in "https://mvnrepository.com"
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Gary Gregory (JIRA)
2017-07-06 08:16:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076142#comment-16076142 ]

Gary Gregory edited comment on LOG4J2-1921 at 7/6/17 8:15 AM:
--------------------------------------------------------------

That site does not pick up SNAPSHOT builds. You need to point your build to https://repository.apache.org/content/repositories/snapshots if you want to test SNAPSHOT builds.


was (Author: garydgregory):
That site does not pick up SNAPSHOT builds. You need to point your build to https://repository.apache.org/content/repositories/snapshots
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Gary Gregory (JIRA)
2017-07-06 08:16:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076142#comment-16076142 ]

Gary Gregory commented on LOG4J2-1921:
--------------------------------------

That site does not pick up SNAPSHOT builds. You need to point your build to https://repository.apache.org/content/repositories/snapshots
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 09:03:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076193#comment-16076193 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

ok, in my Android gradle build, I added

maven { url 'https://repository.apache.org/content/repositories/snapshots' }

and tried accessing it like:

compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.9'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.9'

And I am getting :
Error:Failed to resolve: org.apache.logging.log4j:log4j-api:2.9

What else should I do to include the snapshot build?
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 09:05:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076193#comment-16076193 ]

Ajitha edited comment on LOG4J2-1921 at 7/6/17 9:04 AM:
--------------------------------------------------------

ok, in my Android gradle build, I added

repositories {
mavenCentral()
maven { url 'https://repository.apache.org/content/repositories/snapshots' }
}

and tried accessing it like:

compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.9'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.9'

And I am getting :
Error:Failed to resolve: org.apache.logging.log4j:log4j-api:2.9

What else should I do to include the snapshot build?



was (Author: ajitha):
ok, in my Android gradle build, I added

maven { url 'https://repository.apache.org/content/repositories/snapshots' }

and tried accessing it like:

compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.9'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.9'

And I am getting :
Error:Failed to resolve: org.apache.logging.log4j:log4j-api:2.9

What else should I do to include the snapshot build?
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Gary Gregory (JIRA)
2017-07-06 09:07:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076201#comment-16076201 ]

Gary Gregory commented on LOG4J2-1921:
--------------------------------------

It's {{2.9-SNAPSHOT}}, not {{2.9}} ;-)
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 09:19:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076217#comment-16076217 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

No luck it says:

Error:Failed to resolve: org.apache.logging.log4j:log4j-api:2.9-SNAPSHOT
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Gary Gregory (JIRA)
2017-07-06 09:24:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076230#comment-16076230 ]

Gary Gregory commented on LOG4J2-1921:
--------------------------------------

How about:
{code:javascript}
maven {
url 'https://repository.apache.org/content/repositories/snapshots'
snapshot true
}
{code}
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Gary Gregory (JIRA)
2017-07-06 09:24:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076230#comment-16076230 ]

Gary Gregory edited comment on LOG4J2-1921 at 7/6/17 9:23 AM:
--------------------------------------------------------------

How about:
{code:javascript}
maven {
url 'https://repository.apache.org/content/repositories/snapshots'
snapshot true
}
{code}

?


was (Author: garydgregory):
How about:
{code:javascript}
maven {
url 'https://repository.apache.org/content/repositories/snapshots'
snapshot true
}
{code}
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 09:26:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076232#comment-16076232 ]

Ajitha commented on LOG4J2-1921:
--------------------------------


{code:java}
Error:(11, 0) Could not find method snapshot() for arguments [true] on object of type org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository.

{code}
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 09:33:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076240#comment-16076240 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

My bad! Firewall block. It identified the build now. Will update you shortly!
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 09:46:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076259#comment-16076259 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Android does not support Java 9 classes. It says:


{code:java}
AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: Dex cannot parse version 53 byte code.\nThis is caused by library dependencies that have been compiled using Java 8 or above.\nIf you are using the \u0027java\u0027 gradle plugin in a library submodule add \ntargetCompatibility \u003d \u00271.7\u0027\nsourceCompatibility \u003d \u00271.7\u0027\nto that submodule\u0027s build.gradle file.\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class","sources":[{}],"original":"PARSE ERROR:\nunsupported class file version 53.0\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class\n","tool":"Dex"}
AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]}
{code}
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-06 09:46:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076259#comment-16076259 ]

Ajitha edited comment on LOG4J2-1921 at 7/6/17 9:45 AM:
--------------------------------------------------------

Android does not support Java 9 classes. It throws error in StackLocator.class:


{code:java}
AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: Dex cannot parse version 53 byte code.\nThis is caused by library dependencies that have been compiled using Java 8 or above.\nIf you are using the \u0027java\u0027 gradle plugin in a library submodule add \ntargetCompatibility \u003d \u00271.7\u0027\nsourceCompatibility \u003d \u00271.7\u0027\nto that submodule\u0027s build.gradle file.\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class","sources":[{}],"original":"PARSE ERROR:\nunsupported class file version 53.0\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class\n","tool":"Dex"}
AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]}
{code}



was (Author: ajitha):
Android does not support Java 9 classes. It says:


{code:java}
AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: Dex cannot parse version 53 byte code.\nThis is caused by library dependencies that have been compiled using Java 8 or above.\nIf you are using the \u0027java\u0027 gradle plugin in a library submodule add \ntargetCompatibility \u003d \u00271.7\u0027\nsourceCompatibility \u003d \u00271.7\u0027\nto that submodule\u0027s build.gradle file.\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class","sources":[{}],"original":"PARSE ERROR:\nunsupported class file version 53.0\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class\n","tool":"Dex"}
AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]}
{code}
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Gary Gregory (JIRA)
2017-07-10 00:40:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16079768#comment-16079768 ]

Gary Gregory commented on LOG4J2-1921:
--------------------------------------

ATM, the 2.9-SNAPSHOT log4j-api jar includes a Java 9 classes. We are discussing how to deal with Java 9 and Android on the development mailing list.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-10 07:04:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16079948#comment-16079948 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Thanks for the interim update.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-19 05:28:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16092598#comment-16092598 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Is there a update on this? Can you please find a way to support Android as well?
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-19 05:29:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16092598#comment-16092598 ]

Ajitha edited comment on LOG4J2-1921 at 7/19/17 5:28 AM:
---------------------------------------------------------

Is there a update on this? Can you please find a way to support Android as well? We have been using apache from many days now :) Replacing the logging framework is quite huge at this moment for us. So, if you give us an alternative, it would be great.


was (Author: ajitha):
Is there a update on this? Can you please find a way to support Android as well?
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ralph Goers (JIRA)
2017-07-19 05:34:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16092605#comment-16092605 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

I created a branch named "android" which has a log4j-api-android module in it. I believe it should work in android but I don't have an environment to test it. If you could check out that branch and test it I would then be more comfortable merging it to master. Note that you would use the log4j-api-andoid jar instead of the log4j-api jar.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-19 05:56:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16092624#comment-16092624 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Can you guide me how to pull it via gradle?
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ralph Goers (JIRA)
2017-07-19 07:00:03 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16092682#comment-16092682 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

Gradie? We use Maven as our build tool and git for source control. You can do git clone -b android https://github.com/apache/logging-log4j2. Once you have it checked out run mvn clean install in the root directory.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
kenneth mcfarland
2017-07-19 07:10:10 UTC
Permalink
I can work about 25 hours a week on the Android branch if it would be
useful. I am a student so consider the source, but I've been following and
using this project to pop my open source 🍒
Post by Gary Gregory (JIRA)
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=
com.atlassian.jira.plugin.system.issuetabpanels:comment-
tabpanel&focusedCommentId=16092682#comment-16092682 ]
-------------------------------------
Gradie? We use Maven as our build tool and git for source control. You can
do git clone -b android https://github.com/apache/logging-log4j2. Once
you have it checked out run mvn clean install in the root directory.
Post by Ajitha (JIRA)
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
Labels: Android
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.
Post by Ajitha (JIRA)
{code:java}
LoggerContext ctx = LoggerContext.getContext()
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(
LogManager.ROOT_LOGGER_NAME);
Post by Ajitha (JIRA)
loggerConfig.setLevel(myLogLevel);
ctx.updateLoggers();
{code}
While getting the logger context, I am getting a ClassCastException.
java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext
cannot be cast to org.apache.logging.log4j.core.LoggerContext
Post by Ajitha (JIRA)
05-26 22:33:21.011 E/AndroidRuntime( 9642): at
org.apache.logging.log4j.core.LoggerContext.getContext(
LoggerContext.java:190)
Post by Ajitha (JIRA)
05-26 22:33:21.011 E/AndroidRuntime( 9642): at
org.apache.logging.log4j.core.config.Configurator.
setRootLevel(Configurator.java:323)
Post by Ajitha (JIRA)
Please help here.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Ajitha (JIRA)
2017-07-19 10:28:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16092898#comment-16092898 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

I will update you in a day.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-20 10:21:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16094482#comment-16094482 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Hi Team,

I did as mentioned above. I built logging-log4j2\log4j-api-android from the given branch. It got built successfuly and generated jar. But log4j-core from same branch was not compiling successfully. It was failing. So, I took latest log4j-core jar from "https://repository.apache.org/content/groups/snapshots/org/apache/logging/log4j/log4j-core/2.9-SNAPSHOT/" . I put both the jar in my Android project and then tried to build.

_*Luckily the issue with java 9 classes were not coming this time*_. Thumbs up guys!

But after running it on Android device, I got the "ClassCastException" that is seen in this problem original statement.

My Android side implementation is exactly similar to the application here : https://github.com/loune/log4j2-android

One change in above example is made:

https://github.com/loune/log4j2-android/blob/master/Log4jExampleApp/app/src/main/java/net/loune/log4j2android/AndroidContextSelector.java

Line no 34:

{code:java}
Configuration config = org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getInstance().getConfiguration(source);
{code}


Replaced with:

{code:java}
Configuration config = org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getInstance().getConfiguration(context, source);
{code}


Please check if we are missing something while initialising the Log4j. Log4j has helped us a lot of times :) Expecting your support. Thanks.

-Ajitha Yasmin S
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ralph Goers (JIRA)
2017-07-20 12:37:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16094625#comment-16094625 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

You should not have needed Log4J-core.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Remko Popma (JIRA)
2017-07-20 13:05:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16094647#comment-16094647 ]

Remko Popma commented on LOG4J2-1921:
-------------------------------------

My understanding is that log4j-api-android is an implementation of the Log4j2 API that delegates logging calls to the logging facilities built into Android. So you don't need the "normal" implementation (which is log4j-core).
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Mikael Ståldal (JIRA)
2017-07-20 18:57:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16095198#comment-16095198 ]

Mikael Ståldal commented on LOG4J2-1921:
----------------------------------------

log4j-core does not support Android, and is not needed when you use log4j-api-android.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-21 06:00:03 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16095822#comment-16095822 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Ok, I am rewritting my implementation and checking. Shall update you by my EOD (IST).

Thanks team!
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-21 08:50:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16095974#comment-16095974 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Friends,

I want to give a background on the requirement, so that you can understand my problem better.
I dont want logs to be written to the default Android's adb which is what "android.util.Log.d" is doing. My end user will share that file via email for me to debug their issues/problems.
We wanted to ALWAYS redirect the logs to a file rather than default logging console of Android.
We have two layers - application layer and middleware layer. Log4j was thread-safe to post logs
All other platforms like Windows were using log4j and we were aligned with other platforms of our application.
The code we follow is exactly like in "https://github.com/loune/log4j2-android" . Our application was using v2.3 of log4j-api and log4j-core. And it was fine and due to some issue we wanted to upgrade and we faced the problem.

We were doing following:
1)On the app launch, we initialised log4j as in the example app using my "xml configuration" file as shown in https://github.com/loune/log4j2-android/blob/master/Log4jExampleApp/app/src/main/java/net/loune/log4jexampleapp/App.java
{code:java}
AndroidLog4jHelper.initialise(this.getApplicationContext(), R.raw.log4j_debug);
{code}

2) After that user can anytime change the logging levels through a menu option and when the user changes the log level, we used below code to update log levels.

{code:java}
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(loglvl);
ctx.updateLoggers();
{code}

This was my total use-case.

In latest release og log4j-api-android , I am not able to see any methods which can get my config file and give me a output file with logs written. I am not able to proceed. Is it just possible to remove the "java 9" classes from log4j-core and give us a release addressing our use-case.

Sorry to trouble you guys. We have been benefitted by your library greatly which was very much robust. Please help us here.

-Ajitha Yasmin S
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-21 08:51:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16095974#comment-16095974 ]

Ajitha edited comment on LOG4J2-1921 at 7/21/17 8:50 AM:
---------------------------------------------------------

Friends,

I want to give a background on the requirement, so that you can understand my problem better.
I dont want logs to be written to the default Android's adb which is what "android.util.Log.d" is doing. My end user will share that file via email for me to debug their issues/problems.
We wanted to ALWAYS redirect the logs to a file rather than default logging console of Android.
We have two layers - application layer and middleware layer. Log4j was thread-safe to post logs
All other platforms like Windows were using log4j and we were aligned with other platforms of our application.
The code we follow is exactly like in "https://github.com/loune/log4j2-android" . Our application was using v2.3 of log4j-api and log4j-core. And it was fine and due to some issue we wanted to upgrade and we faced the problem.

We were doing following:
1)On the app launch, we initialised log4j as in the example app using my "xml configuration" file as shown in https://github.com/loune/log4j2-android/blob/master/Log4jExampleApp/app/src/main/java/net/loune/log4jexampleapp/App.java
{code:java}
AndroidLog4jHelper.initialise(this.getApplicationContext(), R.raw.log4j_debug);
{code}

2) After that user can anytime change the logging levels through a menu option and when the user changes the log level, we used below code to update log levels.

{code:java}
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(loglvl);
ctx.updateLoggers();
{code}

This was my total use-case.

In latest release of log4j-api-android , I am not able to see any methods which can get my config file and give me a output file with logs written. As much as I understand it writes logs to the android logging console which is not my use-case.

I am not able to proceed. Is it just possible to remove the "java 9" classes from log4j-core and give us a release addressing our use-case.

Sorry to trouble you guys. We have been benefitted by your library greatly which was very much robust. Please help us here.

-Ajitha Yasmin S


was (Author: ajitha):
Friends,

I want to give a background on the requirement, so that you can understand my problem better.
I dont want logs to be written to the default Android's adb which is what "android.util.Log.d" is doing. My end user will share that file via email for me to debug their issues/problems.
We wanted to ALWAYS redirect the logs to a file rather than default logging console of Android.
We have two layers - application layer and middleware layer. Log4j was thread-safe to post logs
All other platforms like Windows were using log4j and we were aligned with other platforms of our application.
The code we follow is exactly like in "https://github.com/loune/log4j2-android" . Our application was using v2.3 of log4j-api and log4j-core. And it was fine and due to some issue we wanted to upgrade and we faced the problem.

We were doing following:
1)On the app launch, we initialised log4j as in the example app using my "xml configuration" file as shown in https://github.com/loune/log4j2-android/blob/master/Log4jExampleApp/app/src/main/java/net/loune/log4jexampleapp/App.java
{code:java}
AndroidLog4jHelper.initialise(this.getApplicationContext(), R.raw.log4j_debug);
{code}

2) After that user can anytime change the logging levels through a menu option and when the user changes the log level, we used below code to update log levels.

{code:java}
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(loglvl);
ctx.updateLoggers();
{code}

This was my total use-case.

In latest release og log4j-api-android , I am not able to see any methods which can get my config file and give me a output file with logs written. I am not able to proceed. Is it just possible to remove the "java 9" classes from log4j-core and give us a release addressing our use-case.

Sorry to trouble you guys. We have been benefitted by your library greatly which was very much robust. Please help us here.

-Ajitha Yasmin S
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
Labels: Android
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.4.14#64029)
Ralph Goers (JIRA)
2017-07-21 12:44:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096193#comment-16096193 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

Above you mention you use xml configuration but I don't see one in that app. Can you provide that? Log4j-API-android is providing an implementation that we believe makes sense on android but without knowing what your logging configuration does we cannot know for sure.

Log4J-core does not use Java 9.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ralph Goers (JIRA)
2017-07-21 12:44:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096193#comment-16096193 ]

Ralph Goers edited comment on LOG4J2-1921 at 7/21/17 12:44 PM:
---------------------------------------------------------------

Above you mention you use xml configuration but I don't see one in that app. Can you provide that? Log4j-API-android is providing an implementation that we believe makes sense on android but without knowing what your logging configuration does we cannot know for sure.

Log4J-core does not Have any Java 9 classes.


was (Author: ***@dslextreme.com):
Above you mention you use xml configuration but I don't see one in that app. Can you provide that? Log4j-API-android is providing an implementation that we believe makes sense on android but without knowing what your logging configuration does we cannot know for sure.

Log4J-core does not use Java 9.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ralph Goers (JIRA)
2017-07-21 12:47:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096193#comment-16096193 ]

Ralph Goers edited comment on LOG4J2-1921 at 7/21/17 12:46 PM:
---------------------------------------------------------------

Above you mention you use xml configuration but I don't see one in that app. Can you provide that? Log4j-API-android is providing an implementation that we believe makes sense on android but without knowing what your logging configuration does we cannot know for sure.

Log4J-core does not Have any Java 9 classes.

Log4J 2.3 was the last release to support java 6. Is there something in log4j-core that uses Java 7 that android does not allow? Probably a lot actually.


was (Author: ***@dslextreme.com):
Above you mention you use xml configuration but I don't see one in that app. Can you provide that? Log4j-API-android is providing an implementation that we believe makes sense on android but without knowing what your logging configuration does we cannot know for sure.

Log4J-core does not Have any Java 9 classes.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-21 14:08:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096291#comment-16096291 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Refer sample configuration file:

https://github.com/loune/log4j2-android/tree/master/Log4jExampleApp/app/src/main/res/raw
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ralph Goers (JIRA)
2017-07-21 15:21:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096364#comment-16096364 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

OK. The Logcat appender does essentially what log4j-api-android does. But log4j-api-android doesn't have support for the rolling file appender, although it should be possible to include it or something like it. We have made a lot of changes to log4j-core since 2.3 and I have no idea if it can still be made to work in Android.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-21 16:15:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096433#comment-16096433 ]

Ajitha commented on LOG4J2-1921:
--------------------------------

Ok Ralph. In that case, we will also look for alternatives. Thanks for your extensive support. Happy weekend!
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ralph Goers (JIRA)
2017-07-21 17:04:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096526#comment-16096526 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

Although I'm not sure when I will have the time I'd love the see how we can support your sample project. It looks like I should just be able to load it into Android Developer Studio (or Intellij) and test it. But not having ever worked with Android I am certain there will be a learning curve.
Post by Ajitha (JIRA)
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
Labels: Android
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.4.14#64029)
Ajitha (JIRA)
2017-07-23 06:12:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ajitha updated LOG4J2-1921:
---------------------------
Attachment: Log4jExample_using_v2.3.zip

We are working on alternatives. But If you are interested in Android support,

1)Install Studio
2)Follow the wizard and allow your machine to download latest SDK as wizard says.
3)Import the attachment project and
4) You should be able to run the app on any android device
/Users/ajitha3008/StudioProjects/Log4jExample_using_v2.3.zip
P.S: Enable "USB debugging" in device. Google has many links to do the same.
The output log file will be seen in location: /Android/data/com.braingalore.log4jexample/files/logs/app.log

You can open this with notepad. Use ESFileExplorer to reach to the location to take the log file.

Now we are trying to achieve the upgradation of log4j using the instructions that support grade from https://logging.apache.org/log4j/2.x/maven-artifacts.html (Android supports cradle build). The configurations of gradle can be found in the file app/build.gradle . It may be pointing to the "maven" repo of the apache libs. You can change it to point to apache repo and try to solve the issues that you face. My comments in this bug on 06/Jul/17 09:02 will tell how I tried to achieve the changing of maven repo to apache repo.

This could be a learning curve definitely and logToFileWriter is a great need and when this is ready-made people would love to use your app taking "apache" brand in consideration.

-Ajitha Yasmin
Post by Ajitha (JIRA)
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
Labels: Android
Attachments: Log4jExample_using_v2.3.zip
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.4.14#64029)
Ajitha (JIRA)
2017-07-23 06:13:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16097523#comment-16097523 ]

Ajitha edited comment on LOG4J2-1921 at 7/23/17 6:12 AM:
---------------------------------------------------------

We are working on alternatives. But If you are interested in Android support,

1)Install Studio
2)Follow the wizard and allow your machine to download latest SDK as wizard says.
3)Import the attachment project (I have attached in this JIRA) and
4) You should be able to run the app on any android device
/Users/ajitha3008/StudioProjects/Log4jExample_using_v2.3.zip
P.S: Enable "USB debugging" in device. Google has many links to do the same.
The output log file will be seen in location: /Android/data/com.braingalore.log4jexample/files/logs/app.log

You can open this with notepad. Use ESFileExplorer to reach to the location to take the log file.

Now we are trying to achieve the upgradation of log4j using the instructions that support grade from https://logging.apache.org/log4j/2.x/maven-artifacts.html (Android supports cradle build). The configurations of gradle can be found in the file app/build.gradle . It may be pointing to the "maven" repo of the apache libs. You can change it to point to apache repo and try to solve the issues that you face. My comments in this bug on 06/Jul/17 09:02 will tell how I tried to achieve the changing of maven repo to apache repo.

This could be a learning curve definitely and logToFileWriter is a great need and when this is ready-made people would love to use your app taking "apache" brand in consideration.

-Ajitha Yasmin


was (Author: ajitha):
We are working on alternatives. But If you are interested in Android support,

1)Install Studio
2)Follow the wizard and allow your machine to download latest SDK as wizard says.
3)Import the attachment project and
4) You should be able to run the app on any android device
/Users/ajitha3008/StudioProjects/Log4jExample_using_v2.3.zip
P.S: Enable "USB debugging" in device. Google has many links to do the same.
The output log file will be seen in location: /Android/data/com.braingalore.log4jexample/files/logs/app.log

You can open this with notepad. Use ESFileExplorer to reach to the location to take the log file.

Now we are trying to achieve the upgradation of log4j using the instructions that support grade from https://logging.apache.org/log4j/2.x/maven-artifacts.html (Android supports cradle build). The configurations of gradle can be found in the file app/build.gradle . It may be pointing to the "maven" repo of the apache libs. You can change it to point to apache repo and try to solve the issues that you face. My comments in this bug on 06/Jul/17 09:02 will tell how I tried to achieve the changing of maven repo to apache repo.

This could be a learning curve definitely and logToFileWriter is a great need and when this is ready-made people would love to use your app taking "apache" brand in consideration.

-Ajitha Yasmin
Post by Ajitha (JIRA)
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
Labels: Android
Attachments: Log4jExample_using_v2.3.zip
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.4.14#64029)
Gary Gregory
2017-07-23 07:34:48 UTC
Permalink
We definitively got side tracked on this VOTE thread...

Gary
Post by Gary Gregory (JIRA)
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=
com.atlassian.jira.plugin.system.issuetabpanels:comment-
tabpanel&focusedCommentId=16097523#comment-16097523 ]
---------------------------------------------------------
We are working on alternatives. But If you are interested in Android support,
1)Install Studio
2)Follow the wizard and allow your machine to download latest SDK as wizard says.
3)Import the attachment project (I have attached in this JIRA) and
4) You should be able to run the app on any android device
/Users/ajitha3008/StudioProjects/Log4jExample_using_v2.3.zip
P.S: Enable "USB debugging" in device. Google has many links to do the same.
/Android/data/com.braingalore.log4jexample/files/logs/app.log
You can open this with notepad. Use ESFileExplorer to reach to the
location to take the log file.
Now we are trying to achieve the upgradation of log4j using the
instructions that support grade from https://logging.apache.org/
log4j/2.x/maven-artifacts.html (Android supports cradle build). The
configurations of gradle can be found in the file app/build.gradle . It may
be pointing to the "maven" repo of the apache libs. You can change it to
point to apache repo and try to solve the issues that you face. My comments
in this bug on 06/Jul/17 09:02 will tell how I tried to achieve the
changing of maven repo to apache repo.
This could be a learning curve definitely and logToFileWriter is a great
need and when this is ready-made people would love to use your app taking
"apache" brand in consideration.
-Ajitha Yasmin
We are working on alternatives. But If you are interested in Android support,
1)Install Studio
2)Follow the wizard and allow your machine to download latest SDK as wizard says.
3)Import the attachment project and
4) You should be able to run the app on any android device
/Users/ajitha3008/StudioProjects/Log4jExample_using_v2.3.zip
P.S: Enable "USB debugging" in device. Google has many links to do the same.
/Android/data/com.braingalore.log4jexample/files/logs/app.log
You can open this with notepad. Use ESFileExplorer to reach to the
location to take the log file.
Now we are trying to achieve the upgradation of log4j using the
instructions that support grade from https://logging.apache.org/
log4j/2.x/maven-artifacts.html (Android supports cradle build). The
configurations of gradle can be found in the file app/build.gradle . It may
be pointing to the "maven" repo of the apache libs. You can change it to
point to apache repo and try to solve the issues that you face. My comments
in this bug on 06/Jul/17 09:02 will tell how I tried to achieve the
changing of maven repo to apache repo.
This could be a learning curve definitely and logToFileWriter is a great
need and when this is ready-made people would love to use your app taking
"apache" brand in consideration.
-Ajitha Yasmin
Post by Ajitha (JIRA)
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
Labels: Android
Attachments: Log4jExample_using_v2.3.zip
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.
Post by Ajitha (JIRA)
{code:java}
LoggerContext ctx = LoggerContext.getContext()
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(
LogManager.ROOT_LOGGER_NAME);
Post by Ajitha (JIRA)
loggerConfig.setLevel(myLogLevel);
ctx.updateLoggers();
{code}
While getting the logger context, I am getting a ClassCastException.
java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext
cannot be cast to org.apache.logging.log4j.core.LoggerContext
Post by Ajitha (JIRA)
05-26 22:33:21.011 E/AndroidRuntime( 9642): at
org.apache.logging.log4j.core.LoggerContext.getContext(
LoggerContext.java:190)
Post by Ajitha (JIRA)
05-26 22:33:21.011 E/AndroidRuntime( 9642): at
org.apache.logging.log4j.core.config.Configurator.
setRootLevel(Configurator.java:323)
Post by Ajitha (JIRA)
Please help here.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Ralph Goers
2017-07-23 15:04:51 UTC
Permalink
We definitively got side tracked on this VOTE thread…
This isn’t the vote thread. I believe you replied to the wrong email.

Ralph
William Ferguson (JIRA)
2017-09-11 09:25:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16160967#comment-16160967 ]

William Ferguson commented on LOG4J2-1921:
------------------------------------------

I am also interested in using log4j2 on Android.
And like Ajitha I'm wanting to log using a RollingFileAppender instead of Android Log (as Android Log is a circular buffer that is shared among all apps/components on the phone)

I've had a look at the android branch and it seems to just stand up a Logger that will redirect to Android Log.
What work needs to be done to enhance that branch so that on an Android VM we can use RollingFileAppenders?
Post by Ajitha (JIRA)
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
Labels: Android
Attachments: Log4jExample_using_v2.3.zip
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.4.14#64029)
Mounica Kodela (JIRA)
2017-09-12 11:30:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16162816#comment-16162816 ]

Mounica Kodela commented on LOG4J2-1921:
----------------------------------------

Hi Team,

I did not find any log4j-api-android in the below github link to try the above steps to make it work in my android app.

https://github.com/apache/logging-log4j2

Please help me
Post by Ajitha (JIRA)
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
Labels: Android
Attachments: Log4jExample_using_v2.3.zip
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.4.14#64029)
Ralph Goers (JIRA)
2017-09-12 11:37:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16162821#comment-16162821 ]

Ralph Goers commented on LOG4J2-1921:
-------------------------------------

It is on a branch named "android". But please read everything above as it may not do what you want.
Post by Ajitha (JIRA)
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
Labels: Android
Attachments: Log4jExample_using_v2.3.zip
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.4.14#64029)
Mounica Kodela (JIRA)
2017-09-13 07:44:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16164258#comment-16164258 ]

Mounica Kodela commented on LOG4J2-1921:
----------------------------------------

[~***@dslextreme.com] We do not have the exact issue. We have an issue using 2.9.0 for our android application which i reported in LOG4J2-2038

Previously, we were using 2.3. We have a problem with oreo devices with v2.3 which is resolved in 2.9.0 as per the resolution of LOG4J2-1920. So, we need to use 2.9.0 to avoid crashing for Android oreo devices. We need help to resolve this.

Thanks,
Mounica
Post by Ajitha (JIRA)
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
Labels: Android
Attachments: Log4jExample_using_v2.3.zip
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.4.14#64029)
Mounica Kodela (JIRA)
2017-09-13 07:45:01 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16164258#comment-16164258 ]

Mounica Kodela edited comment on LOG4J2-1921 at 9/13/17 7:44 AM:
-----------------------------------------------------------------

[~***@dslextreme.com] We do not have the exact issue. We have an issue using 2.9.0 for our android application which i reported in LOG4J2-2038

Previously, we were using 2.3. We have a problem with oreo devices with v2.3 which is resolved in 2.9.0 as per the status of LOG4J2-1920. So, we need to use 2.9.0 to avoid crashing for Android oreo devices. We need help to resolve this.

Thanks,
Mounica


was (Author: mounicakodela):
[~***@dslextreme.com] We do not have the exact issue. We have an issue using 2.9.0 for our android application which i reported in LOG4J2-2038

Previously, we were using 2.3. We have a problem with oreo devices with v2.3 which is resolved in 2.9.0 as per the resolution of LOG4J2-1920. So, we need to use 2.9.0 to avoid crashing for Android oreo devices. We need help to resolve this.

Thanks,
Mounica
Post by Ajitha (JIRA)
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
Labels: Android
Attachments: Log4jExample_using_v2.3.zip
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.4.14#64029)

Loading...