Bobo
Bobo

Reputation: 9163

How to log Http Request body in Spring MVC?

Just think it will be a useful feature for dev stage. Is it something I can configure or requires a bit coding? Thank you stackers!

Upvotes: 9

Views: 8292

Answers (2)

Israel Zalmanov
Israel Zalmanov

Reputation: 811

Use: spring-mvc-logger

Add to pom.xml:

<dependency>
    <groupId>com.github.isrsal</groupId>
    <artifactId>spring-mvc-logger</artifactId>
    <version>0.2</version>
</dependency>

Add to web.xml:

<filter>
    <filter-name>loggingFilter</filter-name>
    <filter-class>com.github.isrsal.logging.LoggingFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>loggingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Add to log4j.xml:

<logger name="com.github.isrsal.logging.LoggingFilter">
    <level value="DEBUG"/>
</logger>

Upvotes: 5

axtavt
axtavt

Reputation: 242686

Take a look at the AbstractRequestLoggingFilter family of filters.

Aslo it may be convenient to use client-side tools for debugging, such as Firebug or Fiddler.

Upvotes: 3

Related Questions