Configure Logger using SLF4J in Spring MVC

Hello guys, Bushan here, Welcome back to B2 Tech. Today in this post, I will show you how to configure/implement Logger using SLF4J in Spring MVC/Java Application. So let’s begin,

Tools and Technologies used,

  • JDK 1.8.0_121
  • Eclipse Oxygen
  • SLF4J 1.7.12
  • Maven
  • Spring 4.2.1.RELEASE

Project Structure

Jar dependencies

Edit the pom.xml file and add slf4j dependencies in it as follows.


XML configuration file for SLF4J

Create a logback.xml file under the src/main/resources source folder and write the following code in it.


Console Appender – Writes the logs to either System.out or System.err
File Appender – Writes the logs to the File named in the <File> tag.



After running the application the console output and file D:/Logs/logger.log will look like as follows.

About the author

Bushan Sirgur

Well, I am Bushan Sirgur from Banglore, India. Currently, I am working as a Software Developer in a Service Base Company. I am interested in JAVA/J2EE, Angular 2, JavaScript, jQuery, MongoDB.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *