本文介绍了如何在Dropwizard(Jersey)中记录JSON响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何配置Dropwizard来记录JSON响应。
I would like to know how one would configure Dropwizard to log the JSON response.
推荐答案
在dropwizard 0.8.1中(也尝试在0.9.0-SNAPSHOT),添加到 Application.run(...)
:
In dropwizard 0.8.1 (also tried in 0.9.0-SNAPSHOT), add to Application.run(...)
:
import java.util.logging.Logger;
import org.glassfish.jersey.filter.LoggingFilter;
...
public void run(MyApplicationConfiguration conf, Environment env) throws Exception {
// do your stuff and then add LoggingFilter
env.jersey().register(new LoggingFilter(
Logger.getLogger(LoggingFilter.class.getName()),
true)
);
}
要配置记录器,请添加配置文件(例如: conf.yml
):
To configure logger, add in your configuration file (e.g.:conf.yml
):
logging:
loggers:
org.glassfish.jersey.filter.LoggingFilter: INFO
这篇关于如何在Dropwizard(Jersey)中记录JSON响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!