[
https://issues.apache.org/jira/browse/LOG4J2-728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14069996#comment-14069996
]
Nelson MELINA edited comment on LOG4J2-728 at 7/22/14 8:26 AM:
---------------------------------------------------------------
{noFormat}
System.setProperty("log4j2.disable.jmx", "true");
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Log4J2ConfigurationFactory configLog4J2 = new
Log4J2ConfigurationFactory(getAssets());
ConfigurationFactory.setConfigurationFactory(configLog4J2);
logger = LogManager.getLogger();
{noFormat}
This get me a
{noFormat}
Caused by: java.lang.NullPointerException: No Configuration was provided
at
org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:351)
at
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:416)
at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
at
org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
at
org.apache.logging.log4j.LogManager.getLogger(LogManager.java:408)
at com.torointl.log4j2xtest.MyActivity.onCreate(MyActivity.java:35)
{noFormat}
at the " logger = LogManager.getLogger();" line, is there something else i need
to do so that it recognize my new configFactory ?
{code:title=Log4J2ConfigurationFactory.java|borderStyle=solid}
public class Log4J2ConfigurationFactory extends XmlConfigurationFactory {
private AssetManager assetManager;
public Log4J2ConfigurationFactory(AssetManager assetManager) {
super();
this.assetManager = assetManager;
}
@Override
protected ConfigurationSource getInputFromUri(URI configLocation) {
InputStream inputStream = null;
ConfigurationSource configSource = null;
try {
inputStream = assetManager.open("log4j2.xml");
configSource = new ConfigurationSource(inputStream);
} catch (IOException e) {
//Log.e("tag", e.getMessage());
}
return configSource;
}
}
{code}
was (Author: daln):
{noFormat}
System.setProperty("log4j2.disable.jmx", "true");
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Log4J2ConfigurationFactory configLog4J2 = new
Log4J2ConfigurationFactory(getAssets());
ConfigurationFactory.setConfigurationFactory(configLog4J2);
logger = LogManager.getLogger();
{noFormat}
This get me a
{noFormat}
Caused by: java.lang.NullPointerException: No Configuration was provided
at
org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:351)
at
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:416)
at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
at
org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
at
org.apache.logging.log4j.LogManager.getLogger(LogManager.java:408)
at com.torointl.log4j2xtest.MyActivity.onCreate(MyActivity.java:35)
{noFormat}
at the " logger = LogManager.getLogger();" line, is there something else i need
to do so that it recognize my new configFactory ?
> Look for log4j2.xml in assets folder (or the application data) in an Android
> APK.
> ---------------------------------------------------------------------------------
>
> Key: LOG4J2-728
> URL: https://issues.apache.org/jira/browse/LOG4J2-728
> Project: Log4j 2
> Issue Type: Bug
> Components: Configurators
> Affects Versions: 2.0-rc2
> Environment: Android
> Reporter: Nelson MELINA
> Labels: android
>
> To add files in an Android apk, you need to put them in an assets folder and
> then they are in an "assets" folder in the APK.
> Log4j 2 needs to find it there when it exists (not the case now).
> Also would it be possible to load the xml configuration file from the
> application data (
> https://developer.android.com/guide/topics/data/data-storage.html ) ?
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]