[
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:48 AM:
---------------------------------------------------------------
{noFormat}
System.setProperty("log4j2.disable.jmx", "true");
System.setProperty("log4j.configurationFactory",
"com.torointl.log4j2xtest.configuration.Log4J2ConfigurationFactory");
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}
07-22 08:46:12.048 1531-1531/com.torointl.log4j2xtest E/dalvikvm﹕ Could not
find class 'javax.naming.InitialContext', referenced from method
org.apache.logging.log4j.core.lookup.JndiLookup.lookup
07-22 08:46:12.052 1531-1531/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
unable to resolve new-instance 1973 (Ljavax/naming/InitialContext;) in
Lorg/apache/logging/log4j/core/lookup/JndiLookup;
07-22 08:46:12.052 1531-1531/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
unable to resolve exception class 1975 (Ljavax/naming/NamingException;)
07-22 08:46:12.052 1531-1531/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
unable to find exception handler at addr 0x19
07-22 08:46:12.052 1531-1531/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup
(Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
07-22 08:46:12.056 1531-1531/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
rejecting opcode 0x0d at 0x0019
07-22 08:46:12.056 1531-1531/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup
(Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
07-22 08:46:12.056 1531-1531/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier
rejected class Lorg/apache/logging/log4j/core/lookup/JndiLookup;
07-22 08:46:12.068 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [d]
07-22 08:46:12.068 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [d] starting at position 16 in
conversion pattern.
07-22 08:46:12.072 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [thread]
07-22 08:46:12.072 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [thread] starting at position 25
in conversion pattern.
07-22 08:46:12.072 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [level]
07-22 08:46:12.072 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [level] starting at position 35
in conversion pattern.
07-22 08:46:12.076 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [logger]
07-22 08:46:12.076 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [logger] starting at position 47
in conversion pattern.
07-22 08:46:12.092 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [msg]
07-22 08:46:12.112 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in
conversion pattern.
07-22 08:46:12.128 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [n]
07-22 08:46:12.144 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [n] starting at position 56 in
conversion pattern.
07-22 08:46:12.200 1531-1531/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unable to create instance of
com.torointl.log4j2xtest.configuration.Log4J2ConfigurationFactory
java.lang.NoSuchMethodException: <init> []
07-22 08:46:12.200 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.Class.getConstructorOrMethod(Class.java:472)
07-22 08:46:12.200 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.Class.getConstructor(Class.java:446)
07-22 08:46:12.200 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.config.ConfigurationFactory.addFactory(ConfigurationFactory.java:175)
07-22 08:46:12.200 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.config.ConfigurationFactory.addFactory(ConfigurationFactory.java:166)
07-22 08:46:12.204 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.config.ConfigurationFactory.getInstance(ConfigurationFactory.java:128)
07-22 08:46:12.204 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:415)
07-22 08:46:12.204 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
07-22 08:46:12.204 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
07-22 08:46:12.208 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
07-22 08:46:12.208 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
07-22 08:46:12.208 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.LogManager.getLogger(LogManager.java:408)
07-22 08:46:12.208 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
com.torointl.log4j2xtest.MyActivity.onCreate(MyActivity.java:36)
07-22 08:46:12.212 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.app.Activity.performCreate(Activity.java:5231)
07-22 08:46:12.212 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-22 08:46:12.212 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
07-22 08:46:12.212 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
07-22 08:46:12.216 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread.access$800(ActivityThread.java:135)
07-22 08:46:12.216 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-22 08:46:12.216 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.os.Handler.dispatchMessage(Handler.java:102)
07-22 08:46:12.216 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.os.Looper.loop(Looper.java:136)
07-22 08:46:12.216 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread.main(ActivityThread.java:5017)
07-22 08:46:12.220 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.reflect.Method.invokeNative(Native Method)
07-22 08:46:12.220 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.reflect.Method.invoke(Method.java:515)
07-22 08:46:12.220 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-22 08:46:12.220 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-22 08:46:12.224 1531-1531/com.torointl.log4j2xtest W/System.err﹕ at
dalvik.system.NativeStart.main(Native Method)
07-22 08:46:12.232 1531-1531/com.torointl.log4j2xtest W/dalvikvm﹕
threadid=1: thread exiting with uncaught exception (group=0xa4dc6b20)
07-22 08:46:12.240 1531-1531/com.torointl.log4j2xtest E/AndroidRuntime﹕
FATAL EXCEPTION: main
Process: com.torointl.log4j2xtest, PID: 1531
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.torointl.log4j2xtest/com.torointl.log4j2xtest.MyActivity}:
java.lang.NullPointerException: No Configuration was provided
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
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:36)
at android.app.Activity.performCreate(Activity.java:5231)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
{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}
@Plugin(name = "Log4J2ConfigurationFactory", category = "ConfigurationFactory")
@Order(1)
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());
System.out.println("NELSON IOException => " + 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}
07-22 08:44:23.468 1482-1482/com.torointl.log4j2xtest E/dalvikvm﹕ Could not
find class 'javax.naming.InitialContext', referenced from method
org.apache.logging.log4j.core.lookup.JndiLookup.lookup
07-22 08:44:23.468 1482-1482/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
unable to resolve new-instance 1973 (Ljavax/naming/InitialContext;) in
Lorg/apache/logging/log4j/core/lookup/JndiLookup;
07-22 08:44:23.468 1482-1482/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
unable to resolve exception class 1975 (Ljavax/naming/NamingException;)
07-22 08:44:23.472 1482-1482/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
unable to find exception handler at addr 0x19
07-22 08:44:23.472 1482-1482/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup
(Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
07-22 08:44:23.472 1482-1482/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
rejecting opcode 0x0d at 0x0019
07-22 08:44:23.472 1482-1482/com.torointl.log4j2xtest W/dalvikvm﹕ VFY:
rejected Lorg/apache/logging/log4j/core/lookup/JndiLookup;.lookup
(Lorg/apache/logging/log4j/core/LogEvent;Ljava/lang/String;)Ljava/lang/String;
07-22 08:44:23.476 1482-1482/com.torointl.log4j2xtest W/dalvikvm﹕ Verifier
rejected class Lorg/apache/logging/log4j/core/lookup/JndiLookup;
07-22 08:44:23.484 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [d]
07-22 08:44:23.484 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [d] starting at position 16 in
conversion pattern.
07-22 08:44:23.488 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [thread]
07-22 08:44:23.488 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [thread] starting at position 25
in conversion pattern.
07-22 08:44:23.488 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [level]
07-22 08:44:23.488 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [level] starting at position 35
in conversion pattern.
07-22 08:44:23.492 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [logger]
07-22 08:44:23.492 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [logger] starting at position 47
in conversion pattern.
07-22 08:44:23.504 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [msg]
07-22 08:44:23.520 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in
conversion pattern.
07-22 08:44:23.540 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized format specifier [n]
07-22 08:44:23.556 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unrecognized conversion specifier [n] starting at position 56 in
conversion pattern.
07-22 08:44:23.628 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ERROR
StatusLogger Unable to load class Log4J2ConfigurationFactory
java.lang.ClassNotFoundException: Log4J2ConfigurationFactory
07-22 08:44:23.628 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.Class.classForName(Native Method)
07-22 08:44:23.628 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.Class.forName(Class.java:251)
07-22 08:44:23.632 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.Class.forName(Class.java:216)
07-22 08:44:23.632 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.util.Loader.loadClassWithDefaultClassLoader(Loader.java:288)
07-22 08:44:23.632 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.util.Loader.loadClass(Loader.java:283)
07-22 08:44:23.632 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.config.ConfigurationFactory.addFactory(ConfigurationFactory.java:166)
07-22 08:44:23.636 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.config.ConfigurationFactory.getInstance(ConfigurationFactory.java:128)
07-22 08:44:23.636 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:415)
07-22 08:44:23.636 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
07-22 08:44:23.636 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
07-22 08:44:23.636 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
07-22 08:44:23.640 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
07-22 08:44:23.640 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
org.apache.logging.log4j.LogManager.getLogger(LogManager.java:408)
07-22 08:44:23.640 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
com.torointl.log4j2xtest.MyActivity.onCreate(MyActivity.java:36)
07-22 08:44:23.640 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.app.Activity.performCreate(Activity.java:5231)
07-22 08:44:23.644 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-22 08:44:23.644 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
07-22 08:44:23.644 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
07-22 08:44:23.644 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread.access$800(ActivityThread.java:135)
07-22 08:44:23.644 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-22 08:44:23.648 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.os.Handler.dispatchMessage(Handler.java:102)
07-22 08:44:23.648 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.os.Looper.loop(Looper.java:136)
07-22 08:44:23.648 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
android.app.ActivityThread.main(ActivityThread.java:5017)
07-22 08:44:23.648 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.reflect.Method.invokeNative(Native Method)
07-22 08:44:23.648 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.reflect.Method.invoke(Method.java:515)
07-22 08:44:23.652 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-22 08:44:23.652 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-22 08:44:23.652 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
dalvik.system.NativeStart.main(Native Method)
07-22 08:44:23.652 1482-1482/com.torointl.log4j2xtest W/System.err﹕ Caused
by: java.lang.NoClassDefFoundError: Log4J2ConfigurationFactory
07-22 08:44:23.656 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ... 28
more
07-22 08:44:23.656 1482-1482/com.torointl.log4j2xtest W/System.err﹕ Caused
by: java.lang.ClassNotFoundException: Didn't find class
"Log4J2ConfigurationFactory" on path: DexPathList[[zip file
"/data/app/com.torointl.log4j2xtest-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.torointl.log4j2xtest-1,
/system/lib]]
07-22 08:44:23.656 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
07-22 08:44:23.656 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.ClassLoader.loadClass(ClassLoader.java:497)
07-22 08:44:23.660 1482-1482/com.torointl.log4j2xtest W/System.err﹕ at
java.lang.ClassLoader.loadClass(ClassLoader.java:457)
07-22 08:44:23.660 1482-1482/com.torointl.log4j2xtest W/System.err﹕ ... 28
more
07-22 08:44:23.660 1482-1482/com.torointl.log4j2xtest W/dalvikvm﹕
threadid=1: thread exiting with uncaught exception (group=0xa4dc6b20)
07-22 08:44:23.664 1482-1482/com.torointl.log4j2xtest E/AndroidRuntime﹕
FATAL EXCEPTION: main
Process: com.torointl.log4j2xtest, PID: 1482
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.torointl.log4j2xtest/com.torointl.log4j2xtest.MyActivity}:
java.lang.NullPointerException: No Configuration was provided
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
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:36)
at android.app.Activity.performCreate(Activity.java:5231)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
{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}
> 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]