正在装载数据…… ### direct log messages to stdout ### #log4j.appender.stdout=org.apache.log4j.ConsoleAppender #log4j.appender.stdout.Target=System.out #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout #log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{100}:%L lines - %m%n ### direct messages to file hibernate.log ### log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=d:/log4j.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{100}:%L lines - %m%n ### set log levels - for more verbose logging change 'info' to 'debug' ### #log4j.rootLogger=warn, stdout log4j.rootLogger=warn,file #log4j.logger.org.hibernate=info #log4j.logger.org.hibernate=debug ### log HQL query parser activity #log4j.logger.org.hibernate.hql.ast.AST=debug ### log just the SQL #log4j.logger.org.hibernate.SQL=debug ### log JDBC bind parameters ### #log4j.logger.org.hibernate.type=info #log4j.logger.org.hibernate.type=debug ### log schema export/update ### #log4j.logger.org.hibernate.tool.hbm2ddl=debug ### log HQL parse trees #log4j.logger.org.hibernate.hql=debug ### log cache activity ### #log4j.logger.org.hibernate.cache=debug ### log transaction activity #log4j.logger.org.hibernate.transaction=debug ### log JDBC resource acquisition #log4j.logger.org.hibernate.jdbc=debug ### enable the following line if you want to track down connection ### ### leakages when using DriverManagerConnectionProvider ### #log4j.logger.org.hibernate.connection.DriverManagerC package com.cyrcw.test; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.cyrcw.dao.CommenDAO; import com.cyrcw.dao.TWkPersonDAO; import com.cyrcw.filter.ForbiddenCharacters; public class UrlTest { private static final Log log = LogFactory.getLog(UrlTest.class); /** * @param args * @throws Exception */ public static void main(String[] args){ /* CommenDAO commenDAO = new CommenDAO(); String[] sql = new String[2]; sql[0] = "delete from T_ERP_INFO where ERP_USER='***'"; boolean a = commenDAO.executeSqls(sql); System.out.println(a); boolean b = ForbiddenCharacters.checkReg("****功"); */ try { int i = 1/0; } catch(Exception ex) { log.error("出错了",ex); } log.error("error"); log.info("info"); log.debug("debug"); } }
上面是 LOG4J 的配置文件和类中的使用说明,不过还有一点还没有弄明白的就是: 怎么配置 可以一天产生一个日志文件 如果有知道的朋友希望不吝赐教,谢谢 本文来源:http://blog.csdn.net/abccba9978/archive/2007/08/05/1727183.aspx
|