如何在Java Servlet中避免每个请求的控制台日志记录?

huangapple go评论74阅读模式
英文:

How to avoid the console log for each request in a java Servlet?

问题

我有一个Dropwizard应用程序,使用一个Servlet,每个对Servlet的请求都会像这样记录到控制台:

0:0:0:0:0:0:0:1 - - [15/Oct/2020:07:46:43 +0000] "GET /myServletUrl/subUrl/test?foo=var HTTP/1.1" 200 113 "-" "PostmanRuntime/7.26.5" 3169

我已经按照通常的方式在yaml中配置了Dropwizard的日志记录,并且它也起作用了(我在Servlet中展示的日志就像配置中所说的那样)。但是我无法避免这种奇怪的日志... 有任何想法吗?

谢谢!

英文:

I have a dropwizard application, using a servlet, and every request to the servlet is logged to the console like this:

0:0:0:0:0:0:0:1 - - [15/Oct/2020:07:46:43 +0000] "GET /myServletUrl/subUrl/test?foo=var HTTP/1.1" 200 113 "-" "PostmanRuntime/7.26.5" 3169

I have configured the logging of dropwizard in a yaml, as always, and it works (the logs that I show in the servlet works like the config said). But I can't avoid that strange log... ¿any ideas?

Thanks!

答案1

得分: 0

好的,我找到了问题。这个日志来自于Jetty和Dropwizard,不是来自服务器。它被称为"requestLog",你可以在Dropwizard的配置中进行配置(当然也可以禁用)。
就像这样:
https://stackoverflow.com/questions/23505403/turning-off-requestlog

英文:

Ok, I found the problem. The log is from jetty and dropwizard, not from the server. Is called "requestLog" and you can configure it (and disable too, of course) in the dropwizard configuration.
Like here:
https://stackoverflow.com/questions/23505403/turning-off-requestlog

huangapple
  • 本文由 发表于 2020年10月15日 15:49:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/64367078.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定