简体   繁体   中英

Spring Data MongoDB Connection Logging

Is there a way of checking if a mongo connection has been successfully opened during app deployment?

I am not having any connection input returned on logs.

I have this on my log4j properties.

log4j.category.org.springframework.data.mongodb=TRACE

I only get this on my trace related to mongo.

DEBUG [RMI TCP Connection(2)-127.0.0.1] (MongoPersistentEntityIndexCreator.java:122) - Analyzing class class com.marcoremane.spring.entity.Client for index information.

I am doing XML based configurations

<mongo:mongo-client id="mongoClient" host="127.0.0.1" port="27017">
    <mongo:client-options connect-timeout="1000"/>
</mongo:mongo-client>

<mongo:db-factory id="mongoDbFactory" dbname="minib" mongo-ref="mongoClient"/>

<mongo:template db-factory-ref="mongoDbFactory"/>

Try switching on Log4j2 internal logging:

<Configuration status="trace">

Log4j2 internal logging statements will be printed to the console. This should include success or failure of database connectivity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM