Spring Boot – Show Hibernate SQL query
Add the following lines in application.properties to log the Hibernate SQL query. To show sql statement: logging.level.org.hibernate.SQL=debug . To show sql values: logging.level.org.hibernate.type.descriptor.sql=trace
Spring Boot Test – How to disable DEBUG and INFO logs
Run the Spring Boot integration test or unit test, many annoying DEBUG and INFO logs are displayed in the console. To disable the logs, turn off the logging.level in both…
Logback – Duplicate log messages
Review a simple Java application and log a message via Logback. Run above program, the Logback will logs a message twice? This is caused by the Appenders accumulate. To fix…
How to stop logback status INFO at the start of every log?
The logback will output its own status (INFO or WARN) at the start of the program, it’s really annoying! To fix it, add a NopStatusListener in logback.xml
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,…
log4j.xml Examples
Here’s an XML version of log4j properties file, just for sharing. Redirect the logging to console. Redirect the logging to a file. Full example to output the logging to both…
log4j.properties examples
I can’t find many log4j.properties examples, here are a few log4j.properties examples that are used in my project, just for sharing. All logging will be redirected to your console. All…
Logback – Set log file name programmatically
In Logback, it is easy to set a log file name programmatically : 1 - In logback.xml, declares a variable like ${log.name}, 2 - In Java, set the variable via…
Logback – different log file for each thread
In this tutorial, we will show you how to use Logback Mapped Diagnostic Context (MDC) and SiftingAppender to create a separate log file for each thread.
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…