Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 360
Bobo Avatar asked Jan 18 '11 17:01

Bobo


1 Answers

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>
like image 69
Israel Zalmanov Avatar answered Oct 05 '22 22:10

Israel Zalmanov