Dies ist eine alte Version des Dokuments!


LU09c - Logging in Spring Boot

Das Logging funktioniert im Grossen und Ganzen gleich wie bisher mit slf4j.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
public class DemoController {
    private static final Logger log = LoggerFactory.getLogger(DemoController.class);
    ...
        log.error("Error during execution of...:", e);

Neu ist, dass wir die dazugehörigen Einstellungen einfach in unser application.properties schreiben können.

logging.level.root=INFO
logging.level.com.example.demo=DEBUG
logging.file.name=app.log
import lombok.extern.slf4j.Slf4j;
 
@Slf4j
public class DemoController {
    ...
        log.error("Error during execution of...:", e);
  • de/modul/ffit/3-jahr/java/learningunits/lu09/c.1762217449.txt.gz
  • Zuletzt geändert: 2025/11/04 01:50
  • von apeter