标签:
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."); } }
标签:
原文地址:http://blog.csdn.net/iamgongqinghua/article/details/43670745