grizzly不会在请求中记录异常

编程入门 行业动态 更新时间:2024-10-27 22:32:42
本文介绍了grizzly不会在请求中记录异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经设置了这样一个简单的球衣服务器:

I've set up a simple jersey server like this:

ResourceConfig rc = new ResourceConfig().packages("com.example.jersey_test/services"); HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create(API_URI), rc);

我有一个简单抛出异常的bean:

And I have a bean that simply throws an exception:

@Path("persons") public class PersonService { @GET @Produces(MediaType.APPLICATION_JSON) public String getPersons() { java.util.logging.Logger.getGlobal().log(Level.INFO, "test"); throw new RuntimeException("test"); } }

日志输出如下(所以日志记录有效,但未记录异常):

The log output is the following (so logging works, but the exception is not logged):

Jul 01, 2014 10:19:33 PM com.example.jersey_test.services.PersonService getPersons INFO: test

响应是500,看起来如下(所以堆栈跟踪不包括在内):

The response is a 500 with looks like the following (so the stacktrace is not included):

此答案陈述,灰熊应该使用默认的日志记录API。我做错了什么?

As this answer states, grizzly should be using the default logging API. What am I doing wrong?

推荐答案

有一种方法可以启动一个灰熊服务器,它既记录又打印出响应中的异常:

There is a way to start a grizzly server that both logs and prints out exceptions in the response:

HttpServer server = GrizzlyWebContainerFactory.create(getBaseURI(), Collections.singletonMap("javax.ws.rs.Application", "class.that.extends.ResourceConfig"));

更多推荐

grizzly不会在请求中记录异常

本文发布于:2023-10-29 10:43:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539475.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   异常   grizzly

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!