Purfakt
Purfakt

Reputation: 111

How to exclude a specific class for a specific logger with SLF4J

My program has an underlaying system that persist every log in elasticsearch. I have a class that fetches data online and logs it with slf4j log.error(data). This allow the underlaying system to persist the log in elasticsearch, but it also floods the console with every fetched data.

I wish to disable the consoleAppender just for this specific class.

I've seen other post where people would disable the consoleAppender with logback or would exclude all logging from a specific class, but I couldn't find any information on how to disable one logger in one class.

Is this possible?

Upvotes: 4

Views: 8250

Answers (1)

Ryan Stuetzer
Ryan Stuetzer

Reputation: 392

It sounds like you just need to set the logging level for that class. Set it to ERROR, WARN or another level, depending on the level of the messages that are flooding the console. Try modifying the application.properties file by adding something like:

logging.level.com.test.MyClass=WARN

Upvotes: 9

Related Questions