Other Concepts && Tools

Logging

Logging

Production code

To make our code production-ready there a few things to consider, including how to monitor the application’s flow.

Logging is important if you want to diagnose problems or understand what’s happening with your application, as it runs.

But what is logging exactly?

Logging is the process of recording information about usage patterns, activities, operations, and output within an operating system, application, server or another device.

These activities are registered in a log file.

LOGGING IMPORTANCE

  • INFORMATIVE: If properly set, logs can provide useful information, helping us understand what the code is doing.
  • DIAGNOSTIC: stack traces play a part in problem solving, telling us exactly what happened in our code and where, but they can't tell us what happened before the error was thrown. 
  • AUDITING: We can log the events that happened during runtime (diagnostic), but we can also log more abstract business logic events. like user actions or other things that have either administrative value or, more importantly, legal value.

LOGGING Levels

We can classify the entries in our log file in terms of urgency. For that, we use logging levels.

LOGGING TOOLS

Every programming language has at least one logging framework that allows us to store data in different formats.

 

 In Java, we can take a pick between Java’s own logging tools, java.util.logging, or other external frameworks like Logback or the most popular Log4j2.

LIVe coding

Log4j2 in a Spring Boot project

EXERCISE

Car Rental - Rest API with Logging Integration

Logging

By Soraia Veríssimo

Logging

  • 1,513