天道酬勤,学无止境

Empty request logs

问题

我已将此添加到jetty.xml

<Get name="handler">
    <Call name="addHandler">
        <Arg>
            <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler" />
        </Arg>
    </Call>
</Get>
<Ref id="RequestLog">
    <Set name="requestLog">
        <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
            <Arg>
                /home/aromanov/workspaces/odp-server/ru.focusmedia.odp.server.karaf.launcher/data/jettylog/yyyy_mm_dd.request.log
            </Arg>
            <Set name="retainDays">90</Set>
            <Set name="append">true</Set>
            <Set name="extended">true</Set>
            <Set name="logServer">true</Set>
            <Set name="logDispatch">true</Set>
            <Set name="LogTimeZone">GMT</Set>
        </New>
    </Set>
</Ref>

日志文件已创建,但在浏览器中访问页面后(并获得“404,由 Jetty 提供支持”),日志中没有任何内容。 为什么会这样?

回答1
标签

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • Getting an empty ImmutableMultiDict object from jQuery request data
    Trying to upload a file to server but the ImmutableMultiDict object is returning empty. upload.html <html> <head> <title>Upload File Ajax</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(function() { $('#upload-file-btn').click(function() { var form_data = new FormData($('#upload-file')[0]); form_data.append('file', $('input[type=file]')[0].files[0]); console.log(form_data) $.ajax({ url: '/uploadajax', data: form_data, type: 'POST', contentType: false, cache: false, processData: false
  • 从 jQuery 请求数据中获取空的 ImmutableMultiDict 对象(Getting an empty ImmutableMultiDict object from jQuery request data)
    问题 尝试将文件上传到服务器,但 ImmutableMultiDict 对象返回空。 上传.html <html> <head> <title>Upload File Ajax</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(function() { $('#upload-file-btn').click(function() { var form_data = new FormData($('#upload-file')[0]); form_data.append('file', $('input[type=file]')[0].files[0]); console.log(form_data) $.ajax({ url: '/uploadajax', data: form_data, type: 'POST', contentType: false, cache: false, processData: false, async: false, success: function(data) { console.log(
  • Web Api Request Content is empty in action filter
    I have an attribute named Log that tries to log the content of request and response into a text file. I've put that over my Controller to cover all the actions. In LogAttribute I'm reading content as a string (ReadAsStringAsync) so I don't lose request body. public class LogAttribute : ActionFilterAttribute { // .. public override void OnActionExecuting(HttpActionContext actionContext) { // stuff goes here var content = actionContext.Request.Content.ReadAsStringAsync().Result; // content is always empty because request body is cleared } public override void OnActionExecuted
  • Web Api请求内容在操作筛选器中为空(Web Api Request Content is empty in action filter)
    问题 我有一个名为Log的属性,该属性试图将请求和响应的内容记录到一个文本文件中。 我将其放在控制器上,以涵盖所有操作。 在LogAttribute我以字符串( ReadAsStringAsync )的形式读取内容,因此我不会丢失请求正文。 public class LogAttribute : ActionFilterAttribute { // .. public override void OnActionExecuting(HttpActionContext actionContext) { // stuff goes here var content = actionContext.Request.Content.ReadAsStringAsync().Result; // content is always empty because request body is cleared } public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { // other stuff goes here var content = actionContext.Request.Content.ReadAsStringAsync().Result; //
  • Ajax 请求成功但结果为空(Ajax request succeeds but result is empty)
    问题 我正在构建一个 Google Chrome 浏览器扩展,它使用$.ajax请求将数据从网页发送到我的服务器(当前使用本地主机托管)。 在扩展程序有权访问的网页上下文中执行的content_script.js文件(更多关于内容脚本)运行以下代码: //note: encode64String is assigned earlier in the script... $.ajax({ type: "POST", url: "http://localhost:8888/quartzsite/uploadendpoint.php", type: "jsonp", data: {img: encode64String}, contentType: "application/x-www-form-urlencoded;charset=UTF-8", success: function(data){ console.log("The ajax request succeeded!"); console.log("The result is: "); console.log(data); }, error: function(){ console.log("The request failed"); } }); 问题是Ajax请求成功,但它返回的data参数为空
  • ActionContext.ActionArguments 在 IAuthenticationFilter 中为空(ActionContext.ActionArguments Is Empty In IAuthenticationFilter)
    问题 背景: 我想使用使用 Ninject 注入的IAuthenticationFilter的实现来验证对我的 Web API 的 POST 请求。 要验证请求,我需要访问请求正文。 问题: 我通常用来访问请求负载的ActionContext.ActionArguments是空的,当我尝试在过滤器中访问它时。 题: 如何在IAuthenticationFilter实现中访问 POST 请求有效负载? 为什么ActionContext.ActionArguments在IAuthenticationFilter实现中为空,但如果我的过滤器实现ActionFilterAttribute则具有值? 代码: 过滤器实现: public class AuthenticateFilter : IAuthenticationFilter { private const string AuthenticationHeader = "X-Auth-Token"; private const string UserHeader = "X-Auth-User"; private readonly ILog log; public AuthenticateFilter(ILog log) { this.log = log; } public Task AuthenticateAsync
  • Nginx请求体过大报错413,request_body日志频频为空,实战排查全过程
    承接之前文章使用openresty来搭建https代理与日志打印,随着时间的流逝,我搭建的openresty已经上了公司的生产服务器,就在这周五出现了一个新问题,于是我开始了探索了历程!那么问题是什么呢?又是怎么解决的呢?下面我们带着疑问往下看! 出现这个问题之后,公司同事找到我,说道:“我在网上查了加了client_max_body_size参数为20m的大小怎么日志打印的request_body为空呢?”。然后我当时脑子是懵的,于是将他修改的配置还原到原来的样子,看到了如下这大大的报错信息,我想:这报错信息很明显啦。信心满满的我找他要到了请求的报文和接口地址,发现请求报文大到原生记事本打开直接崩掉,最终我还是开始问题的排查! openresty请求体过大导致413报错 首先,我认为既然用nginx代理转发接口地址,nginx所在服务器IP和域名与转发地址一定是网络互通的,你可以使用ping或者telnet的方式来检查。我认为这是有必要的,因为你所排查的问题都得建立在网络互通前提下,要不然排查途中发现很浪费你的时间和耐心,同样也会影响你的排查思路和心情!所以检查完以后我的网络是互通的,那么继续排查! 其次,nginx是一个轻量级服务,请求的过大的话需要更改请求体大小限制的,而且你的请求是从浏览器发出的,浏览器是有一个请求头的Content-Length默认为1m的大小
  • 如何避免我的 querysnapshot.foreach 上的循环?(How i can avoid the loop on my querysnapshot.foreach?)
    问题
  • Axios post request.body is empty object
    I am trying to post data from my react. Backend - express. Here is backend code: var express = require('express'); var app = express(); var bodyParser = require("body-parser"); var methodOverride = require("method-override"); var mongoose = require("mongoose"); var expressSanitizer = require("express-sanitizer"); mongoose.connect("mongodb://localhost/blog-react"); //app config app.set("view engine", "ejs"); app.use(express.static("public")); app.use(bodyParser.urlencoded({extended: true})); //must be after parser app.use(expressSanitizer()); app.use(methodOverride("_method")); //schema config
  • getGeneratedKeys returns an empty ResultSet
    In one sentence: Statement.getGeneratedKeys() is occasionally returning an empty ResultSet, and I'm trying to figure out why. Background: I am keeping track of users' requests regarding orders and some of their items. I have two tables, call them Header and Detail. To link the header and details properly, Header has a SERIAL column named request_id, which I use when inserting rows into Detail. This has been working fine for a long time (as far as I know), but recently I noticed that sometimes, the ResultSet returned by getGeneratedKeys() is empty. To clarify, here is the code (identifying
  • ActionContext.ActionArguments Is Empty In IAuthenticationFilter
    Background: I want to authenticate a POST request to my web API using an implementation of IAuthenticationFilter injected using Ninject. To authenticate a request I need access to request body. Problem: ActionContext.ActionArguments, which I usually use to access request payload, is empty when I try to access it inside the filter. Question: How to access POST request payload inside an IAuthenticationFilter implementation? Why ActionContext.ActionArguments is empty inside an IAuthenticationFilter implementation, but has values if my filter implements ActionFilterAttribute? Code: Filter
  • Unity3D - Post is empty when doing a UnityWebRequest
    I'm doing a UnityWebrequest and it's working fine, but upon checking what's is the post in my PHP I found that the post is an empty array and the file is aswell. I found a StackOverflow post that has a similar problem. But it's solution did not work for me. So why is the post and file empty? I'm running this on a local server. UnityWebRequest POST to PHP not work Web request static IEnumerator Post(string url, string bodyJsonString) { UnityWebRequest request = new UnityWebRequest(url, "POST"); request.chunkedTransfer = false; Debug.Log(bodyJsonString); byte[] bodyRaw = Encoding.UTF8.GetBytes
  • JSF: why is empty test in rendered invoked during apply request values phase during form submission under request scoped POST REDIRECT GET
    This question is spawned from the partial answer to JSF2: why does empty test in rendered of panelGroup in composite prevent action from being called? In the following an Element is an @Entity with a name and id. A view.xhtml JSF page takes the id as a viewParam and uses setID(Long id) of the @ManagedBean @RequestScoped ElementController to trigger loading of the corresponding Element by id from database (that plays no further role in the question) and this found Element is set as the 'current' Element available (for historical reasons by a slightly different name) as Element getSelected()
  • 使用nginx真正记录POST请求正文(而不是“-”)(Really logging the POST request body (instead of “-”) with nginx)
    问题 我正在尝试记录POST正文,并将$request_body添加到http子句中的log_format中,但是在我使用以下命令发送POST请求后, access_log命令仅将“-”作为正文打印出来: curl -d name=xxxx myip/my_location 我的log_format(在http子句中): log_format client '$remote_addr - $remote_user $request_time $upstream_response_time ' '[$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; 我的位置定义(在server子句中): location = /c.gif { empty_gif; access_log logs/uaa_access.log client; } 如何从curl打印实际的POST数据? 回答1 除非确实需要,否则Nginx不会解析客户端请求主体,因此它通常不会填充$request_body变量。 例外情况是在以下情况: 它将请求发送到代理, 或fastcgi服务器。 因此,您确实需要将proxy
  • getGeneratedKeys 返回一个空的 ResultSet(getGeneratedKeys returns an empty ResultSet)
    问题
  • Why my custom ClientHttpRequestInterceptor with empty response
    I have done the following for my custom logging interceptor public class HttpLoggingInterceptor implements ClientHttpRequestInterceptor { private final static Logger log = LoggerFactory.getLogger(HttpLoggingInterceptor.class); @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { logRequest(request, body); ClientHttpResponse response = execution.execute(request, body); logResponse(response); return response; } private void logRequest(HttpRequest request, byte[] body) throws IOException { log.info("Request URI
  • How to insert data in Azure SQL using tedious.js after verifying that the data doesn't exists in the database?
    This is the first time I'm using tedious.js, I still don't understand it a lot. I'm mostly going over their documentation here. Following is the logic in the POST method. Check if the tag already exists for the given statement id If the tag exists, return the message to the client If the tag doesn't exist, insert the tag in the database. This is my post method in express.js to add "tag" // POST add tags router.post('/tag', function(req, res){ // get the body const data = req.body; // sql query to check if the tag already exists for the given id or not. let sql = `SELECT * FROM tags WHERE
  • 为什么我的自定义 ClientHttpRequestInterceptor 响应为空(Why my custom ClientHttpRequestInterceptor with empty response)
    问题 我已经为我的自定义日志拦截器完成了以下操作 public class HttpLoggingInterceptor implements ClientHttpRequestInterceptor { private final static Logger log = LoggerFactory.getLogger(HttpLoggingInterceptor.class); @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { logRequest(request, body); ClientHttpResponse response = execution.execute(request, body); logResponse(response); return response; } private void logRequest(HttpRequest request, byte[] body) throws IOException { log.info("Request URI : {}, Method : {}, Headers : {}
  • fetch() POST request to Express.js generates empty body {}
    Goal: send some defined string data from HTML in a fetch() function e.g. "MY DATA" My code: HTML <!DOCTYPE html> <html> <body> <script type="text/javascript"> function fetcher() { fetch('/compute', { method: "POST", body: "MY DATA", headers: { "Content-Type": "application/json" } } ) .then(function(response) { return response.json(); }) .then(function(myJson) { console.log(myJson); }); } </script> </body> </html> Server.js var express = require("express"); var app = express(); var compute = require("./compute"); var bodyParser = require("body-parser"); //not sure what "extended: false" is for
  • fetch gives an empty response body
    I have a react/redux application and I'm trying to do a simple GET request to a sever: fetch('http://example.com/api/node', { mode: "no-cors", method: "GET", headers: { "Accept": "application/json" } }).then((response) => { console.log(response.body); // null return dispatch({ type: "GET_CALL", response: response }); }) .catch(error => { console.log('request failed', error); }); The problem is that the response body is empty in the .then() function and I'm not sure why. I checked examples online and it looks like my code should work so I'm obviously missing something here. The thing is, if I