我们遇到了log4j和tomcat的问题。我们在尝试重命名文件时收到拒绝访问的消息,但检查权限一切正常。任何想法都行不通?
2016-07-06 20:00:35,422 Log4j2-AsyncLoggerConfig-2 ERROR Unable to rename file /var/log/tomcat/logs/log.log to /log-2016-07-06-16-1.log - Permission denied
权限
drwxr-xr-x. 3 tomcat tomcat 8.0K Jul 7 16:57 tomcat
drwxr-xr-x. 2 tomcat tomcat 4.0K Jul 5 15:31 logs
log4j config
<RollingFile name="file" fileName="/var/log/tomcat/logs/log.log" append="true"
filePattern="log-%d{yyyy-MM-dd-HH}-%i.log">
<PatternLayout pattern="%d %p [%c] - %m%n"/>
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10 MB"/>
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
答案 0 :(得分:0)
想出这个,试图写信给/
,因为我在filePattern
指令中没有apth。
答案 1 :(得分:0)
尝试
<Properties>
<Property name="log-path">/var/log/tomcat/logs</Property>
</Properties>
<RollingFile name="file" fileName="${log-path}/log.log" append="true"
filePattern="${log-path}/log-%d{yyyy-MM-dd-HH}-%i.log">
<PatternLayout pattern="%d %p [%c] - %m%n"/>
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10 MB"/>
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>