我在Tomacat中运行的maven框架中有一个Java spring应用程序。
IDE:Eclipse
创建 log4j.properties file
并将其放在名为“log”的文件夹中。右键单击日志文件夹。
Selected 'Build Path --> Use as source folder'
以下是 log4j.properties
。
log = /log4j
log4j.rootLogger = DEBUG, FILE
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${log}/log.out
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd}-%t-%x-%-5p-%-10c:%m%n
这是我记录
的方式static Logger log = Logger.getLogger(Sample.class.getName());
log.info("sample");
我的问题是
1. While maven install, log file created in D:\log4j\log.out
2. I deleted the file. then run the application
3. Now file created. But no content. Its size is 0 KB.
4. When I stop the application, the file is updated with the content.
我错在哪里?