MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » Log4j有关问题求助!

Log4j有关问题求助!(2)

www.MyException.Cn  网友分享于:2013-12-25  浏览:4次

Log   log=LogFactory.getLog(this.getClass());
log.debug( "This   is   a   debug   message! ");
log.trace( "This   is   a   trace   message! ");
log.info( "This   is   a   info   message! ");
log.warn( "This   is   a   warn   message! ");
log.error( "This   is   a   error   message ");
log.fatal( "This   is   a   fatal   message ");

在commons-logging.properties中
    org.apache.commons.logging.Log
      =org.apache.commons.logging.impl.Log4JCategoryLog;
  log4j.rootLogger=INFO,console,file
      #   define   a   appender   named   console,which   is   set   to   be   a   ConsoleAppender
            log4j.appender.console=org.apache.log4j.ConsoleAppender
              #   define   a   appender   named   file,which   is   set   to   be   a   RollingFileAppender
            log4j.appender.file=org.apache.log4j.RollingFileAppender
            log4j.appender.file.File=log.txt
            log4j.appender.console.layout=org.apache.log4j.SimpleLayout
           
              #   Assign   a   PatternLayout   to   file   appender
              log4j.appender.file.layout=org.apache.log4j.PatternLayout
            log4j.appender.file.layout.ConversionPattern=%t   %p-   %m%n


------解决方案--------------------
LogFactory.getLog(this.getClass());好像不是log4j
Logger log = Logger.getLogger(this.getClass());

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有