log4j.properties配置
log4j.logger.webAplLogger=info, logFile log4j.appender.logFile=org.apache.log4j.FileAppender log4j.appender.logFile.Threshold=warn log4j.appender.logFile.Append=true log4j.appender.logFile.File=D:/logs/log.log4j log4j.appender.logFile.layout=org.apache.log4j.PatternLayout log4j.appender.logFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
方法的使用:
public static void main(String[] args) { Logger fileLog = Logger.getLogger("webAplLogger"); fileLog.info("info"); fileLog.warn("warn"); }
时间: 2024-10-29 12:47:30