简体   繁体   English

Olingo v4 + log4j2

[英]Olingo v4 + log4j2

I could not find any information about Olingo v4 system logging like spring boot has.我找不到任何有关 Olingo v4 系统日志记录的信息,例如 spring 引导。 Tutorial includes slf4j, so there must be internal logging in framework教程包含slf4j,所以framework里面必须有内部日志

   <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>${slf4j.version}</version>
      <scope>runtime</scope>
    </dependency>

But I was not able to find any occurrences of logging configuration in tutorial or sample code.但我无法在教程或示例代码中找到任何日志配置。 I want to use log4j2 for logging purposes and I'm expecting specific parameter to be used in web.xml like it works in spring boot我想使用 log4j2 进行日志记录,我希望在 web.xml 中使用特定参数,就像它在 spring 引导中一样工作

<context-param>
    <param-name>log4jConfiguration</param-name>
    <param-value>log4j2.properties</param-value>
</context-param>

Moreover I found ODataDebugCallback implementation for v2 - Debug Support and Error Handling此外,我找到了 v2 的 ODataDebugCallback 实现 -调试支持和错误处理

But it's for v2 and does not work in v4但它适用于 v2,不适用于 v4

Is there any context-param to use or something similar to ODataDebugCallback for logging purposes?是否有任何上下文参数可供使用或类似于 ODataDebugCallback 的东西用于记录目的?

Small case description.小案例说明。

I have created Olingo v4 OData API above data base.我在数据库上方创建了 Olingo v4 OData API。 One of it key features is dynamic metadata build.其中一个关键特性是动态元数据构建。 It worked fine initially but when I'm creating new table I'm getting它最初工作得很好,但是当我创建新表时,我得到了

{
    "error": {
        "code": null,
        "message": "OData Library: An exception without message text was thrown."
    }
}

And no catch in OData servlet并且在 OData servlet 中没有任何问题

        try {
            /*session, storage, handler, edm providers init here*/

            // let the handler do the work
            handler.process(req, resp);
        } catch (Exception e) {
            log.error("Server Error occurred in ODataServlet", e); //app is not getting here
            throw new ServletException(e);
        } finally {
            log.debug("========== Request end ==========");
        }

And my log还有我的日志

[DEBUG] ODataServlet - ========== Request begin ==========
[DEBUG] ODataServlet - Received GET request /myOdataServer.svc/$metadata from 0:0:0:0:0:0:0:1
[DEBUG] JDBCFactory - Opening connection to jdbc:postgresql://host/card_storage
[DEBUG] ODataServlet - ========== Request end ==========

I'm hoping to get more info from framework about error: stack trace, line number, something.我希望从框架中获得更多关于错误的信息:堆栈跟踪、行号等。

To get the exception trace, You may check the ServerCoreDebugger class.要获取异常跟踪,您可以检查 ServerCoreDebugger class。

Basically you need to register DebugSupport to the ODataHttpHandler, and add query parameter like 'odata-debug=json' to your request url to work with the DefaultDebugSupport to get the exception trace from response.基本上,您需要将 DebugSupport 注册到 ODataHttpHandler,并在您的请求 url 中添加查询参数(如“odata-debug=json”)以使用 DefaultDebugSupport 从响应中获取异常跟踪。

handler.register(new DefaultDebugSupport());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM