SmartHttpLogger
Auto http logger for SpringBoot
.
introduction
you can logging automatically http req/res information that come to your application's api.
2019-04-19 20:20:00 ERROR 62593 --- [nio-8888-exec-2] j.s.s.logging.SmartHttpLogger:
[ 'method' = 'GET', 'url' = '/user/100', 'request' = 'null', 'status' = '401', 'response' = '{"status":401,"message":"authorization exception"}', 'time' = '82ms' ]
2019-04-19 20:20:02 INFO 62593 --- [nio-8888-exec-3] j.s.s.logging.SmartHttpLogger:
[ 'method' = 'POST', 'url' = '/user', 'request' = '{"id":"1000","name":"kc","score":100}', 'status' = '200', 'response' = '{"id":"1000","name":"kc","score":100}', 'time' = '35ms' ]
Usage
1. adding dependency on pom
<dependency>
<groupId>jp.spring-boot-reference</groupId>
<artifactId>smart-http-logger</artifactId>
<version>1.0.0</version>
</dependency>
2. modify log output as you like.
you can hide some http information by setting.
smarthlog.output.method=false
smarthlog.output.status=false
Then, output become
2019-04-19 20:20:00 ERROR 62593 --- [nio-8888-exec-2] j.s.s.logging.SmartHttpLogger:
['url' = '/user/100', 'request' = 'null', 'response' = '{"status":401,"message":"authorization exception"}', 'time' = '82ms' ]
you can mask header information.
you can hide header information by adding setting on application.properties
like below.
smartlog.header.secrets=Authorization,host
then, Authorization
and host
header's information is hidden by xxxxxxxxxxxxxx
expression.
installation
adding dependency on pom.xml
<dependency>
<groupId>jp.spring-boot-reference</groupId>
<artifactId>smart-http-logger</artifactId>
<version>1.0.0</version>
</dependency>