java 什么是 spring MVC 中的调试日志记录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5133153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what is debug logging in spring MVC
提问by skaffman
My spring MVC is not working and i am getting error resource not found.
我的 spring MVC 无法正常工作,并且找不到错误资源。
I have heard about debug logging.
我听说过调试日志记录。
Is it something that i can turn on and i can see more detail that where is the problem or
是不是我可以打开某些东西,并且我可以看到问题出在哪里的更多细节,或者
is it something i need to program in every file only that message will be shown which i hard coded in file
是不是我需要在每个文件中编程,只显示我在文件中硬编码的消息
回答by skaffman
Spring uses the Apache Commons Logging API, which in turn uses either internal Java logging, or log4j (if available). See this part of the docsfor a fuller explanation.
Spring 使用 Apache Commons Logging API,后者又使用内部 Java 日志记录或 log4j(如果可用)。有关更完整的解释,请参阅文档的这一部分。
"debug logging" refers to the fact that Spring does a lot of verbose logging at "debug level", which is normally not recorded. You can reconfigure your logging, however, to show this level of information if required. Again, see the above link.
“调试日志”指的是 Spring 在“调试级别”做了很多详细的日志记录,通常不会记录。但是,如果需要,您可以重新配置日志记录以显示此级别的信息。再次,请参阅上面的链接。
回答by esaj
In your log4j.properties, set the logging level for Spring to DEBUG, something along the lines of
在您的 log4j.properties 中,将 Spring 的日志记录级别设置为 DEBUG,类似于
log4j.logger.org.springframework = DEBUG, <Some appender>
回答by Jér?me Verstrynge
From a personal blog post, the required maven dependencies are:
从个人博客文章,所需的 maven 依赖项是:
<properties>
...
<spring.version>3.1.2.RELEASE</spring.version>
<slf4j.version>1.7.1</slf4j.version>
<logback.version>0.9.30</logback.version>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
The above enables Logback. Check the corresponding documentation to set the desired logging level.
以上启用了Logback。检查相应的文档以设置所需的日志记录级别。