what is debug logging in spring MVC

2019-04-09 21:50发布

My spring MVC is not working and i am getting error resource not found.

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

3条回答
萌系小妹纸
2楼-- · 2019-04-09 22:10

From a personal blog post, the required maven dependencies are:

<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.

查看更多
劫难
3楼-- · 2019-04-09 22:15

Spring uses the Apache Commons Logging API, which in turn uses either internal Java logging, or log4j (if available). See this part of the docs for a fuller explanation.

"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.

查看更多
虎瘦雄心在
4楼-- · 2019-04-09 22:31

In your log4j.properties, set the logging level for Spring to DEBUG, something along the lines of

log4j.logger.org.springframework = DEBUG, <Some appender>
查看更多
登录 后发表回答