How to log the operations of Spring Data MongoDB?

1.8k Views Asked by At

We are using Spring Data MongoDB to operate mongodb. I was using Spring Data JPA to manage some relationship database. The SQL can be printed into the log file (log4j or logback). But for the mongoDB operation, there is no log output. Is there any way can let our debug what document (json object) has been insert or updete into the MongoDB base on Spring Data MongoDB module?

1

There are 1 best solutions below

1
On

Spring data mongodb contains the LoggingEventListener.

Unluckily, the EventListeners do not support all batch operations. If you have batch operations, you may need to add your own costum logging.