简体   繁体   English

REST服务器返回由Jetty驱动的HTTP 404错误,如何查找服务器日志条目?

[英]REST server returns HTTP 404 error powered by Jetty, How to find server log entries?

I have a REST application deployed in FUSE ESB 6.1. 我在FUSE ESB 6.1中部署了REST应用程序。 There are many services exposed to the external clients. 有许多向外部客户端公开的服务。 The issue is, Sometimes clients receive HTTP 404 Not Found with the following html. 问题是,有时客户端会收到带有以下html的HTTP 404 Not Found。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 Not Found </title>
</head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /context/api/service1. Reason:
<pre>    Not Found</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>

I can see this is due to a wrong service name. 我可以看到这是由于错误的服务名称。

But i can't find any related log entries in server logs. 但是我在服务器日志中找不到任何相关的日志条目。 Is there any option to see these Jetty Error details in the REST server? 是否可以在REST服务器中查看这些Jetty错误详细信息? Possibly any Jetty logs ? 可能有Jetty日志吗?

As with any servlet container, you can redirect 404 errors to a JSP, servlet, whatever, and simply log the URL yourself. 与任何servlet容器一样,您可以将404错误重定向到JSP,servlet等等,并且只需自己记录URL。

From the Jetty documentation : 码头文件

Error code example: 错误代码示例:

 <error-page> <error-code>404</error-code> <location>/jspsnoop/ERROR/404</location> </error-page> 

Exception example: 异常示例:

 <error-page> <exception-type>java.io.IOException</exception-type> <location>/jspsnoop/IOException</location> </error-page> 

You can also catch 404 errors that happen outside your application context: 您还可以捕获在应用程序上下文之外发生的404错误:

Server level 404 error 服务器级别404错误

It is possible to get a page not found when a request is made to the server for a resource that is outside of any registered contexts. 向服务器请求任何已注册上下文之外的资源时,都有可能找不到页面。 As an example, you have a domain name pointing to your public server IP, yet no context is registered with Jetty to serve pages for that domain. 例如,您有一个指向您的公共服务器IP的域名,但没有向Jetty注册任何上下文来为该域提供页面。 As a consequence, the server, by default, gives a listing of all contexts running on the server. 因此,默认情况下,服务器会列出服务器上运行的所有上下文的列表。

One of the quickest ways to avoid this behavior is to create a catch all context. 避免此行为的最快方法之一是创建一个捕获所有上下文。 Create a "root" web app mapped to the "/" URI, and use the index.html redirect to whatever place with a header directive. 创建映射到“ /” URI的“根” Web应用程序,并使用index.html重定向到标头指令的任何位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM