Java 我在哪里可以查看 Eclipse 中的 Tomcat 日志文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2233053/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 05:02:39  来源:igfitidea点击:

Where can I view Tomcat log files in Eclipse?

javaeclipsetomcatlogging

提问by Blankman

Where can I view Tomcat log files in Eclipse?

我在哪里可以查看 Eclipse 中的 Tomcat 日志文件?

For some reason my Tomcat installation/log folder is always empty.

出于某种原因,我的 Tomcat 安装/日志文件夹始终为空。

BTW, does Tomcat dump to the log file after a while or is it immediate?

顺便说一句,Tomcat 会在一段时间后转储到日志文件还是立即转储?

采纳答案by royalsampler

Go to the "Server" view, then double-click the Tomcat server you're running. The accesslog files are stored relative to the path in the "Server path" field, which itself is relative to the workspace path.

转到“服务器”视图,然后双击您正在运行的 Tomcat 服务器。该访问日志文件存储相对于在“服务器路径”字段,这本身就是相对于工作空间路径的路径。

回答by harschware

@royalsampler said:

@royalsampler 说

Go to the Servers view in Eclipse then right click on the server and click Open. The log files are stored in a folder realative to the path in the "Server path" field.

转到 Eclipse 中的服务器视图,然后右键单击服务器并单击打开。日志文件存储在与“服务器路径”字段中的路径相关的文件夹中。

Since the path field is uneditable, you can also "Open Launch Configuration", click Arguments tab, copy the VM argument for catalina.base (within quotes). This is the full path of your WTP webapp directory. Copying the value to the clipboard can save you the laborious task of browsing the file system to the path.

由于路径字段不可编辑,您还可以“打开启动配置”,单击参数选项卡,复制 catalina.base 的 VM 参数(在引号内)。这是 WTP webapp 目录的完整路径。将值复制到剪贴板可以省去将文件系统浏览到路径的繁重任务。

Also note you should be seeing the output to the log file in your Console view as you run or debug.

另请注意,您应该在运行或调试时在控制台视图中看到日志文件的输出。

回答by codesta

I'm not sure if you were after catalina.out or one of the other logs produced by Tomcat.

我不确定您是在使用 catalina.out 还是 Tomcat 生成的其他日志之一。

But, if you're after the catalina.out log file then follow the directions below:

但是,如果您使用 catalina.out 日志文件,请按照以下说明操作:

  • In the servers tab, double-click on the Tomcat Server. You will get a screen called Overview.

  • Click on "Open launch configuration". Click on the "Common" tab.

  • Towards the bottom of the screen you can check the "File" checkbox and then specify a file that can be used to log your console (catalina.out) output.

  • Finally, restart the Tomcat server.

  • 在服务器选项卡中,双击 Tomcat 服务器。您将看到一个名为概览的屏幕。

  • 单击“打开启动配置”。单击“通用”选项卡。

  • 在屏幕底部,您可以选中“文件”复选框,然后指定一个可用于记录控制台 (catalina.out) 输出的文件。

  • 最后,重启Tomcat服务器。

回答by Steve Mitchell

Another forum provided this answer:

另一个论坛提供了这个答案:

Ahh, figured this out. The following system properties need to be set, so that the "logging.properties" file can be picked up.

Assuming that the tomcat is located under an Eclipse project, add the following under the "Arguments" tab of its launch configuration:

啊,想通了。需要设置以下系统属性,以便可以提取“logging.properties”文件。

假设 tomcat 位于 Eclipse 项目下,在其启动配置的“Arguments”选项卡下添加以下内容:

-Dcatalina.base="${project_loc}\<apache-tomcat-5.5.23_loc>" 
-Dcatalina.home="${project_loc}\<apache-tomcat-5.5.23_loc>" 
-Djava.util.logging.config.file="${project_loc}\<apache-tomcat-5.5.23_loc>\conf\logging.properties" 
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 

http://www.coderanch.com/t/442412/Tomcat/Tweaking-tomcat-logging-properties-file

http://www.coderanch.com/t/442412/Tomcat/Tweaking-tomcat-logging-properties-file

回答by JRun

Double click and open the server. Go to 'Arguments'. -Dcatalina.base= .. something. Go to that something. Your logs are there.

双击打开服务器。转到“参数”。-Dcatalina.base= .. 东西。去那个东西。你的日志在那里。

回答by Santosh

Looks like the logs are scattered? I found access logs under <ProjectLocation>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\logs

看起来日志是分散的?我在下面找到了访问日志 <ProjectLocation>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\logs

回答by Vineela Thonupunuri

If you want logs in a separate file other than the console: Double click on the server--> Open Launch Configuration--> Arguments --> add -Dlog.dir = "Path where you want to store this file" and restart the server.

如果您想在控制台以外的单独文件中登录:双击服务器--> 打开启动配置--> 参数--> 添加 -Dlog.dir = "Path where you want to store this file" 并重新启动服务器。

Tip: Make sure that the server is not running when you are trying to add the argument. You should have log4j or similar logging framework in place.

提示:当您尝试添加参数时,请确保服务器未运行。你应该有 log4j 或类似的日志框架。

回答by onlyme

if you're after the catalina.out log and you are using eclispe with tomcat, this works for me:

如果你在 catalina.out 日志之后并且你正在使用带有 tomcat 的 eclispe,这对我有用:

  • create catelina.out some where in your computer. In my case, I put it in logs directory of my tomcat install directory e.g: /opt/apache-tomcat-7.0.83/logs/catena.out
  • go to your eclipse, in the servers tab, double-click on the Tomcat Server. You will get a screen called Overview.
  • Click on "Open launch configuration". Then click on the "Common" tab.
  • At standard input and output section, check "output file", click on file system and then selected the folder where your create your catelina.out.
  • Finally, restart the Tomcat server.
  • 在您的计算机中的某个位置创建 catelina.out。就我而言,我将它放在我的 tomcat 安装目录的日志目录中,例如:/opt/apache-tomcat-7.0.83/logs/catena.out
  • 转到您的 Eclipse,在服务器选项卡中,双击 Tomcat 服务器。您将看到一个名为概览的屏幕。
  • 单击“打开启动配置”。然后单击“通用”选项卡。
  • 在标准输入和输出部分,选中“输出文件”,单击文件系统,然后选择创建 catelina.out 的文件夹。
  • 最后,重启Tomcat服务器。