android - loging with log4j stackoverflow error -
i trying add log statements in code.
using logconfigurator, wrote following code in mainactivity -
public class mainactivity extends activity { logger log = logger.getlogger(mainactivity.class); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); logconfigurator logconfigurator = new logconfigurator(); logconfigurator.setfilename(environment.getexternalstoragedirectory() + file.separator + "myapp" + file.separator + "logs" + file.separator + "log4j.txt"); logconfigurator.setrootlevel(level.debug); logconfigurator.setlevel("org.apache", level.error); logconfigurator.setfilepattern("%d %-5p [%c{2}]-[%l] %m%n"); logconfigurator.setmaxfilesize(1024 * 1024 * 5 * 1024 ); logconfigurator.setimmediateflush(true); logconfigurator.configure(); log.info("execution of method oncreate started"); mytask mtask = new mytask(); mtask.execute(); log.info("execution of method oncreate ended"); }
it worked properly. when add
logger log = logger.getlogger(jsonconversion.class);
in class named jsonconversion , more classes, following error in logcat
07-11 04:32:27.693: e/androidruntime(3963): fatal exception: main 07-11 04:32:27.693: e/androidruntime(3963): java.lang.stackoverflowerror 07-11 04:32:27.693: e/androidruntime(3963): @ org.apache.log4j.categorykey.equals(categorykey.java:47) 07-11 04:32:27.693: e/androidruntime(3963): @ java.util.hashtable.get(hashtable.java:271) 07-11 04:32:27.693: e/androidruntime(3963): @ org.apache.log4j.hierarchy.getlogger(hierarchy.java:273) 07-11 04:32:27.693: e/androidruntime(3963): @ org.apache.log4j.hierarchy.getlogger(hierarchy.java:247) 07-11 04:32:27.693: e/androidruntime(3963): @ org.apache.log4j.logmanager.getlogger(logmanager.java:228) 07-11 04:32:27.693: e/androidruntime(3963): @ org.apache.log4j.logger.getlogger(logger.java:117) 07-11 04:32:27.693: e/androidruntime(3963): @ com.example.news_android_mobile_application_cd.jsonconversion.<init>(jsonconversion.java:25) 07-11 04:32:27.693: e/androidruntime(3963): @ com.example.news_android_mobile_application_cd.mainactivity.<init>(mainactivity.java:25)
i have added log4j-1.2.17.jar , android-logging-log4j-1.0.3.jar . can me out ?
well don't know exact answer following might 1 of reasons -
- there static methods in program, use log in method made them non static , created different objects in different classes, led stackoverflow.
- i made log variable static , did work !
one more thing, size of file should kept in mind. if size of data written exceeds file size, multiple files created.
Comments
Post a Comment