Sign in

Logging in Spring boot is very simple and involves only a few steps. Here they are:

In each of your code files, add the following line at the beginning of the class:

private static final Logger LOGGER=LoggerFactory.getLogger(MyClass.class);

Now you can easily log anything that you want by adding this logger line:

LOGGER.info(“any logger message that you want”);

There are 5 logging levels available in the logger. They are:

  • Error
  • Warn
  • Info
  • Debug
  • Trace

You can use any of those by calling the respective methods. In earlier point, we have called the info method of the logger.

In your application.properties file…

Amster

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store