java - log4j INFO level not logging information -


i using log4j ogging project. unfortunately, not able log info levels in application havelogged manually.. though logging database logs perfectly!

here properties file :

log4j.rootlogger=off  log4j.appender.servicelog=org.apache.log4j.rollingfileappender log4j.appender.servicelog.file=c:/users/prateekg/desktop/log4j/log  log4j.appender.dblog=org.apache.log4j.rollingfileappender log4j.appender.dblog.file=c:/users/prateekg/desktop/log4j/dblog  log4j.appender.servicelog.maxfilesize=1mb log4j.appender.servicelog.maxbackupindex=1  log4j.appender.servicelog.layout=org.apache.log4j.patternlayout log4j.appender.servicelog.layout.conversionpattern=%d{yyyy-mm-dd hh:mm:ss} %-5p %c{1}:%l - %m%n  log4j.appender.dblog.layout=org.apache.log4j.patternlayout log4j.appender.dblog.layout.conversionpattern=%d{yyyy-mm-dd hh:mm:ss} %-5p %c{1}:%l - %m%n  log4j.category.servicelog=info,servicelog log4j.category.org.springframework.jdbc=debug, dblog 

edit:

this log code:

public static logger logger = logger.getlogger(controller.class); boolean commit=false; public controller(dashboarddao dao,messageprocessor mp, handlerfactory hf, toxml xml) {     this.dao=dao;     this.mp=mp;     this.hf=hf;     this.xml=xml;     propertyconfigurator.configure("log4j.properties"); }  public boolean controlflow(message message) {     handler handler=null;     string data[]=null;     boolean flag=false;      int count=0;      handler=initializehandlerfactory(message);     data=getmessage(handler,message);     flag=validate(data);     count=geteventcount(data);     //commit=mp.flag1;     //system.out.println("the flag "+flag);      if(flag)     {         system.out.println("inside flag");         string elementnames[]=dao.getelementnames(integer.parseint(data[0]));         system.out.println("no of tags "+elementnames.length);         logger.info("no of tags in generated xml "+elementnames.length);         file xmlfile=xml.converttoxml(elementnames, data);         logger.info("temporary xml file created");         logger.info("data sent insertion");         dao.insert(count, data,xmlfile);         boolean f=xmlfile.delete();         system.out.println("temp xml file deleted: "+f);         if(f)         {         logger.info("temporary xml file deleted");         commit=mp.flag1;         }         else             logger.info("error in deleting temporary xml file");     } 

you either need define logger logger.getlogger("servicelog") or define custom appender matching class

log4j.category.my.package.controller=info,servicelog 

or package

log4j.category.my.package=info,servicelog 

also, calling propertyconfigurator.configure("log4j.properties"); not necessary, default configuration file name being looked log4j @ startup.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -