Skip to main content

Posts

Showing posts from January 10, 2018

Logging with logback

Greetings!

It is important to add proper loggers into our application because when something bad happens, it is the way to gather related information.

There are multiple libraries for logging in Java like JUL, log4j, logback. Spring uses logback as the default library.
When we add any starter dependency that will add starter-logging as well since it depends transitively on the logging starter.

howto-configure-logback-for-logging

Complete source code, todoapp
$ git clone https://github.com/slmanju/todoapp.git
$ cd todoapp
$ gradle clean bootrun
Log Levels Log messages can be used in several levels.
ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF
If WARN is enabled, then WARN, ERROR, FATAL will be logged
Appenders Appenders responsible for writing log statements.
ConsoleAppender – writes messages to the system consoleFileAppender – appends messages to a fileRollingFileAppender – extends the FileAppender with the ability to roll over log filesSMTPAppender – sends log mess…