Skip to content

Latest commit

 

History

History

livelessons-operations-logging

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Lesson 3: Creating Operations-Friendly Microservices (Logging)

Introduction

Provides an overview of default logging with Spring Boot.

Building and running the sample

Use the following commands to build run the application:

$ mvn clean package
$ java -jar target/livelessons-operations-logging-1.0.0-SNAPSHOT.jar

Understanding the code

The LoggerExample @Component shows the many different logging solutions that exist and how they all redirect to the same output. You won’t usually mix logging libraries in your own code, but you may well depend on many different third-party libraries which have each chosen a different way to log.

Notice consistent format of the log, the color output and the additional whitespace that is included around stacktraces.

You can experiment with different logging levels by adding logging.level properties to the application.properties file, eg:

logging.level.org.springframework.boot: DEBUG

If you want to write the log to a file uncomment the following line from application.properties:

logging.file: myapp.log