目前我正在运行 Jersey 2.14(和 Grizzly 2.16),尽管我没有看到新/旧版本在日志记录方面有太大差异。
我正在尝试禁用如下消息:
INFO: 2 * Server responded with a response on thread Grizzly-worker(15)
2 < 201
2 < Location: somewhere
每当我在生产环境中做任何事情时。我什至有一个准系统类,我认为它会隐藏客户端和服务器的方法:
@Provider
public class MyLoggingFilter extends LoggingFilter
{
@Override
public void filter(ClientRequestContext context) throws IOException
{
// Do nothing.
//super.filter(context);
}
}
和
@Provider
public class MyLoggingFilter extends LoggingFilter
{
@Override
public void filter(ContainerRequestContext context) throws IOException
{
// Do nothing.
//super.filter(context);
}
}
值得注意的是,正如我通过跟踪语句发现的那样,这些方法正在受到攻击。
是否有一些 ServerProperty 或其他可切换选项,我没有看到它对此负责,因此我可以在生产过程中将其关闭?
谢谢!
最佳答案
我找到了解决办法: 因为
@Provider
装饰,LoggingFilter 已自动注册。通过删除它,我能够控制日志记录,从而禁用日志记录消息。
关于java - 如何禁用 Jersey 2.x 中的日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28706309/