logback java.io.FileNotFoundException :(权限被拒绝)

时间:2014-04-18 10:11:57

标签: maven tomcat7 slf4j logback

在启动Tomcat 7时,我有以下异常:

openFile(/home/myuser/tomcat7/logs/myapp/myapp.log,true)调用失败。 java.io.FileNotFoundException:/home/myuser/tomcat7/logs/myapp/myapp.log(权限被拒绝)         at java.io.FileNotFoundException:/home/myuser/tomcat7/logs/myapp/myapp.log(Permission denied)

我在logback.xml中的配置:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="fileAppender" class="ch.qos.logback.core.FileAppender">
<file>/home/myuser/tomcat7/logs/myapp/myapp.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>myapp.%d{yyyy-MM-dd}.log</fileNamePattern>

<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>

<append>true</append>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern>
</encoder>
</appender>

<logger name="ma.package"   level="DEBUG" />

<root level="INFO">
<appender-ref ref="fileAppender" />
</root>
</configuration>

我已尝试手动创建文件并使用chmod 666,没有任何工作。我希望每个人都有解决方案。

1 个答案:

答案 0 :(得分:0)

好的,解决方案是将tomcat组和用户设置为此文件夹

chown tomcat7:tomcat7 /home/myUser/tomcat7/logs