依赖:
log4j log4j 1.2.17
在classpass路径下加入log4j.properties
LOG_DIR=D:/logs/data-odlog4j.rootCategory=error,od,Console #将error错误输出到od和Console,具体输出到哪里看log4j.appender.od和log4j.appender.Console定义log4j.appender.Console=org.apache.log4j.ConsoleAppender #输出位置为控制台log4j.appender.Console.layout=org.apache.log4j.PatternLayout #输出格式log4j.category.com.data.od=error,od #log4j.category.包名 : 将com.data.od包下的error错误输出到od,具体输出到哪里看log4j.appender.od定义log4j.additivity.com.hsf=false #com.hsf包下的日志不输出到控制台log4j.category.org.springframework = error,Springlog4j.additivity.org.springframework =falselog4j.category.com.hsf = error,HSFlog4j.additivity.com.hsf =falselog4j.appender.od=org.apache.log4j.RollingFileAppenderlog4j.appender.od.File=${LOG_DIR}/data-od.loglog4j.appender.od.MaxFileSize=5000000log4j.appender.od.layout=org.apache.log4j.PatternLayoutlog4j.appender.od.layout.ConversionPattern=[%d{ yyyy-MM-dd HH:mm:ss}] %-5p %c %x - %m%nlog4j.appender.Spring=org.apache.log4j.RollingFileAppenderlog4j.appender.Spring.File=${LOG_DIR}/spring.loglog4j.appender.Spring.MaxFileSize=5000000log4j.appender.Spring.layout=org.apache.log4j.PatternLayoutlog4j.appender.Spring.layout.ConversionPattern=[%d{ yyyy-MM-dd HH:mm:ss}] %-5p %c %x - %m%nlog4j.appender.HSF=org.apache.log4j.RollingFileAppenderlog4j.appender.HSF.File=${LOG_DIR}/hsf.loglog4j.appender.HSF.MaxFileSize=5000000log4j.appender.HSF.layout=org.apache.log4j.PatternLayoutlog4j.appender.HSF.layout.ConversionPattern=[%d{ yyyy-MM-dd HH:mm:ss}] %-5p %c %x - %m%n# SqlMap logging configuration.#log4j.logger.com.ibatis=DEBUG#log4j.category.com.ibatis.common.jdbc.SimpleDataSource=DEBUG,ibatis#log4j.category.com.ibatis.common.jdbc.ScriptRunner=DEBUG,ibatis#log4j.category.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG,ibatislog4j.category.java.sql=DEBUG, sql log4j.additivity.java.sql=falselog4j.appender.sql=org.apache.log4j.RollingFileAppenderlog4j.appender.sql.File=${LOG_DIR}/sql.loglog4j.appender.sql.MaxFileSize=5000000log4j.appender.sql.layout=org.apache.log4j.PatternLayoutlog4j.appender.sql.layout.ConversionPattern=[%d{ yyyy-MM-dd HH:mm:ss}] %-5p %c %x - %m%n