Java 在此文件 localhost_access_log.2014-08-30.txt 上出现访问被拒绝的 apache tomcat 错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25579459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Got apache tomcat error that access denied on this file localhost_access_log.2014-08-30.txt?
提问by Anand Maheshwari
I installed Apache tomcate on Windows 7 OS. I just installed apache and make it available in eclipse. When i run any simple application on server it will say 404: page not found and in console it will print the error message like this.
我在 Windows 7 操作系统上安装了 Apache tomcate。我刚刚安装了 apache 并使其在 eclipse 中可用。当我在服务器上运行任何简单的应用程序时,它会说 404: page not found 并且在控制台中它会打印这样的错误消息。
SEVERE: Failed to open access log file [C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\localhost_access_log.2014-08-30.txt]
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\localhost_access_log.2014-08-30.txt (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.apache.catalina.valves.AccessLogValve.open(AccessLogValve.java:1117)
at org.apache.catalina.valves.AccessLogValve.startInternal(AccessLogValve.java:1224)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:185)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1137)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I cannot understand what the things is happen is this??? Please help me.
我不明白这是怎么回事???请帮我。
回答by sidcreative
It seems that your current user is not having rights on the tomcat folder.
您当前的用户似乎没有对 tomcat 文件夹的权限。
I also faced the same problem and solved it by giving rights to the logged in user on the tomcat folder.
我也遇到了同样的问题,并通过为 tomcat 文件夹上的登录用户授予权限来解决它。
For your case :
对于您的情况:
Go to >>"C:\Program Files\Apache Software Foundation\Tomcat 7.0" folder Right Click>>Properties>>security Tab
转到>>“C:\Program Files\Apache Software Foundation\Tomcat 7.0”文件夹右键单击>>属性>>安全选项卡
provide required rights to currently logged in user.
为当前登录的用户提供所需的权限。
回答by Vikas Kalapur
Open Tomcat C:\Program Files\Apache Software Foundation <br>(Right Click on Tomcat 8.5 ( as per Your Version)<br>
→Properties <br>
→Select Security Tab <br>
→Edit <br> →Select Your System <br> →Check or Allow all the Boxes <br>
→Click on Apply <br>
→Restart Program
Open Tomcat C:\Program Files\Apache Software Foundation <br>(Right Click on Tomcat 8.5 ( as per Your Version)<br>
→Properties <br>
→Select Security Tab <br>
→Edit <br> →Select Your System <br> →Check or Allow all the Boxes <br>
→Click on Apply <br>
→Restart Program
回答by leonidos79
Alternatively, you may decide to instruct embedded Tomcat instance to keep its log files in a different location, and outside Windows's native "Program Files" directory. Especially when it comes to latest Windows versions, it is not a good practice to write or keep any file with variable content (i.e. the file that is created or written to at runtime) in program files directory.
或者,您可以决定指示嵌入式 Tomcat 实例将其日志文件保存在不同的位置,并在 Windows 的本机“程序文件”目录之外。特别是对于最新的 Windows 版本,在程序文件目录中写入或保留任何具有可变内容的文件(即在运行时创建或写入的文件)并不是一个好习惯。
Search for TOMCAT_HOME/conf/server.xml for "AccessLogValve", and specify alternative directory for log files as demonstrated below:
在 TOMCAT_HOME/conf/server.xml 中搜索“AccessLogValve”,并指定日志文件的替代目录,如下所示:
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="c:\work\tomcat\logs"
prefix="localhost_access_log." suffix=".log" pattern="common"/>
The key attribute here is "directory".
这里的关键属性是“目录”。