简体   繁体   English

如何查看 org.codehaus.jackson 日志消息 - 使用 logging.properties

[英]How to see org.codehaus.jackson log messages - using logging.properties

I am trying to deserialize incoming PUT request with JSON request body using org.codehaus.jackson package and I am receiving error message The request sent by the client was syntactically incorrect .我正在尝试使用org.codehaus.jackson包反序列化带有 JSON 请求正文的传入PUT请求,我收到错误消息The request sent by the client was syntactically incorrect How can I get more detailed log/error messages in my Pivotal TC server logs, eg in catalina.log ?如何在我的 Pivotal TC 服务器日志中获取更详细的日志/错误消息,例如在catalina.log中?

I have added the following line to logging.properties:我在 logging.properties 中添加了以下行:

org.codehaus.level = FINEST

But NO messages from org.codehaus is displayed in my log, although the error message is displayed on web page.但是我的日志中org.codehaus消息,尽管错误消息显示在网页上。 Maybe codehaus does not support Java logging and I should configure J4Log or similar another logging facility?也许codehaus不支持 Java 日志记录,我应该配置 J4Log 或类似的其他日志记录工具?

My Jackson version is 1.9.13 , I am using Pivotal tc server from Spring Tools Suite (3.8) .我的Jackson 版本是 1.9.13 ,我正在使用Spring Tools Suite (3.8)中的 Pivotal tc 服务器。

For what you say it seems that you're trying to change the tomcat logging.properties.对于您所说的,您似乎正在尝试更改 tomcat logging.properties。

That's usually a bad idea as you may want different logging on different webApps loaded in the same Tomcat server.这通常是一个坏主意,因为您可能希望在同一 Tomcat 服务器中加载的不同 web 应用程序上进行不同的日志记录。

What you should do is configure the log4j in your project.你应该做的是在你的项目中配置 log4j。 Usually Java projects define a "resource" folder.通常 Java 项目定义一个“资源”文件夹。 You should add in there a file called您应该在其中添加一个名为

log4j.properties log4j.properties

and add in there the following:并在其中添加以下内容:

log4j.rootLogger=ERROR,stdout
# Logger for jackson lib
log4j.logger.org.codehaus=TRACE

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%p\t%d{ISO8601}\t%r\t%c\t[%t]\t%m%n

This is extracted from the default log4j configuration and will log in the standard output that for Tomcat is redirected to the catalina.out log file.这是从默认的 log4j 配置中提取的,并将记录 Tomcat 的标准输出,该输出被重定向到 catalina.out 日志文件。 You may want to read the documentation at https://docs.oracle.com/cd/E29578_01/webhelp/cas_webcrawler/src/cwcg_config_log4j_file.html explaining how to redirect the logging to a different file and how to use rolling appenders so you keep some history您可能需要阅读https://docs.oracle.com/cd/E29578_01/webhelp/cas_webcrawler/src/cwcg_config_log4j_file.html上的文档,解释如何将日志重定向到不同的文件以及如何使用滚动附加程序,以便您保持一些历史

Hopefully this will work!希望这会奏效!

The request sent by the client was syntactically incorrect客户端发送的请求语法错误

^^^ This message is created by the HTTP servlet processing the client request and not by the jackson mapper. ^^^ 此消息是由处理客户端请求的 HTTP servlet 创建的,而不是由 jackson 映射器创建的。 You could find the related log messages under spring-mvc logger name: org.springframework.web .您可以在 spring-mvc 记录器名称下找到相关的日志消息: org.springframework.web

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

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