码迷,mamicode.com
首页 > 其他好文 > 详细

log4j简单demo

时间:2015-02-09 16:07:13      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

pom.xml

 <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
          <version>1.6.6</version>
      </dependency>
      <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
          <version>1.6.6</version>
      </dependency>
      <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>1.2.16</version>
      </dependency>


log4j.properties

#可以设置级别:debug>info>error
#debug:显示debug、info、error
#info:显示info、error
#error:只error
#log4j.rootLogger=debug,appender1
log4j.rootLogger=info,appender1
#log4j.rootLogger=error,appender1

#输出到控制台
log4j.appender.appender1=org.apache.log4j.ConsoleAppender
#样式为TTCCLayout
log4j.appender.appender1.layout=org.apache.log4j.TTCCLayout


LoginControl.java

public class LoginControl {

    private static Logger logger = Logger.getLogger(LoginControl.class);

    public void ProtocolReceiver() {

        logger.debug("This is debug message.");
        logger.info("This is info message.");
        logger.error("This is error message.");

	}
}


 

log4j简单demo

标签:

原文地址:http://blog.csdn.net/iamgongqinghua/article/details/43670745

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!