作者:毕老爷666 | 来源:互联网 | 2023-09-24 18:59
j2ee应用部署在tomcat中(linux),期望日志输入到log4j.properties中配置的文件里,classes目录下log4j.properties中内容如下:
j2ee应用部署在tomcat中(linux),期望日志输入到log4j.properties中配置的文件里,
classes目录下log4j.properties中内容如下:
1 2 3 4 5 6 7 8 9
| log4j.rootLogger=INFO,file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.Append=true
log4j.appender.file.MaxFileSize=1024KB
log4j.appender.file.Threshold=INFO
**log4j.appender.file.file=/opt/tomcat-myapp/logs/myapp.log**
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.COnversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n |
java代码:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.quartz.Job;
import java.io.Serializable;
public ABC implements Job,Serializable {
private static final Logger logger = LoggerFactory.getLogger(ABC.class);
public void execute(JobExecutionContext context) throws JobExecutionException {
logger.info("test.....");
}
}
但发现myapp.log中仅有小部分日志信息,代码中logeer.info(....)都输入到tomcat的catalina.out中去了,如何解决?