August 14, 2022

Logback – Disable logging in Unit Test

While the unit test is running in the IDE, the Logback is showing a lot of configuration or status like this. It is really annoying, especially for the failed test, because I need to scroll down manually for the error message! To fix it, create an empty configuration file as logback-test.xml, and save it under $project/src/test/resources. Alternatively, add a NopStatusListener

Logback – Disable logging in Unit Test Read More

logback.xml Examples

Here are a few logback.xml examples that are used in my projects, just for sharing. All logging will be redirected to console. All logging will be redirected to a file logs/app.log. Furthermore, this log file will be archived daily or when the file size is larger than 10MB. Send error logs to email. Logs Asynchronously that make logging faster. Send logs to a separate log file, the log file name is defined at runtime, via MDC. Set the log file name ${log.name} programmatically, via System.setProperty

logback.xml Examples Read More