有时,在滚动日志文件时,似乎会出现一些问题:“无法删除日志文件”,“无法移动日志文件”。
Error: java.nio.file.FileSystemException a.log -> directory\a-2011-08-09-2.log: The process cannot access the file because it is being used by another process.
以下是log4j配置:
<RollingFile name="a" fileName="${sys:catalina.base}/logs/a.log" append="true" createOnDemand="true" filePattern="${sys:catalina.base}/logs/a-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<Pattern>%d{ISO8601}|%-5p|%i|%T|%s|%R|%t|%c{1} - %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<DefaultRolloverStrategy max="25"/>
</RollingFile>