package com.cnse.log.log4jLog; import org.apache.log4j.Logger; public class Log4jLog { Logger logger = Logger.getLogger(Log4jLog.class); public void getLog4jLog() { logger.info("這是log4j的日誌記錄工具...."); } public static void main(String[] args) { Log4jLog l4log=new Log4jLog(); l4log.getLog4jLog(); } } //=======================\\ ##??log4j???????,????,???,????## log4j.rootLogger=info,console,file log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=-----------------------------------------------------------------------------------%nLevel:[%p]%nTime:[%d]%nClass:[%c]%nMessage:[%m]%n log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.file=d\:\\logs\\project_log.log log4j.appender.file.DatePattern='.'yyyy-MM-dd log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH\:mm\:ss,SSS}_%t method\:%l%n%m%n log4j.logger.java.sql.Connection=debug log4j.logger.java.sql.Statement=debug log4j.logger.java.sql.PreparedStatement=debug