Add Logging Messages in Spring 5.1 - All Java Config Version

Add Logging Messages in Spring 5.1 - All Java Config Version
The Problem
In Spring 5.1, the Spring Development team changed the logging levels internally. As a result, by default you will no longer see the red logging messages at the INFO level. This is different than in the videos.


The Solution
If you would like to configure your app to show similar logging messages as in the video, you can make the following updates. Note, you will not see the EXACT same messages, since the Spring team periodically changes the text of the internal logging messages. However, this should give you some additional logging data.



Overview of the steps
0. Create a logging properties file
1. Create a configuration class to configure the parent logger and console handler

Detailed Steps
0. Create a logging properties file
This properties file will define the logging levels for the application. The props file sets the logger level to FINE. For more detailed logging info, you can set the logging level to level to FINEST.  You can read more about the logging levels at http://www.vogella.com/tutorials/Logging/article.html
File: src/mylogger.properties
---
1. Create a configuration class to configure the parent logger and console handler
This class will set the parent logger level for the application context. It will also set the logging level for console handler. The logging levels are loaded from the configuration file using the @PropertySource annotation. The fields are injected using the @Value annotation. This class also has a @PostConstruct method to handle the actual configuration.
File: MyLoggerConfig.java

Comments

Popular posts from this blog

Nginx

AWS Configuration For RDS(postgres),ElastiCache(Redis) with ElasticBean

Use @Initbinder in Spring MVC

CSRF Protection using Synchronizer Tokens

How to read Dates with Hibernate

CSRF Protection using Double Submitted Cookies

The TRUE difference between [] and {{}} bindings in Angular

Hibernate and Primary Keys