Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queries in MongoTemplate Logs with ObjectId Format. #4873

Open
ganeshbabugb opened this issue Jan 14, 2025 · 2 comments
Open

Queries in MongoTemplate Logs with ObjectId Format. #4873

ganeshbabugb opened this issue Jan 14, 2025 · 2 comments
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement

Comments

@ganeshbabugb
Copy link

When any operations made through MongoTemplate, I set the log level to DEBUG using the following configuration:
logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG.

This allows me to view the queries executed by MongoTemplate, which is helpful. However, the issue is that the query logs display ObjectId in the oid format, which cannot be directly executed in the MongoDB Compass client.

Is there a way to log the queries in the ObjectId("") format instead? I couldn’t find a solution for this issue. If a solution already exists, please let me know. If not, it would be great to have this functionality implemented.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 14, 2025
@mp911de
Copy link
Member

mp911de commented Jan 14, 2025

We use Document.toJson() which internally uses JsonMode.RELAXED. Logging is a recurring theme. Do you want to investigate how to introduce JsonWriterSettings for logging purposes in MongoTemplate and ReactiveMongoTemplate?

@mp911de mp911de added status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 14, 2025
@ganeshbabugb
Copy link
Author

Yes, exactly what i am looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants