[
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
> 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)