Outils pour utilisateurs

Outils du site


techniques:slf4j_log4j_lockback_et_java.util.logging

SLF4J

The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction1 for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.

The underlying logging backend is determined at runtime by adding the desired binding to the classpath and may be the standard Sun Java logging package java.util.logging,[2] log4j, logback[3] or tinylog.[4][5]

It is not itself a logging library, but a generic interface to one of many logging libraries.

Remarque : Un bémole, ne permet pas d'utilise le niveau de sévérité FATAL. Mais y a moyen de s'en sortir avec la notion de “Marker” ; For example, any log statement of level ERROR can be tagged with the “FATAL” marker.

Changer le niveau de sévérité :

  1. faire ca et tester

<sxh java>

  ((ch.qos.logback.classic.Logger)LoggerFactory.getLogger("abc.xyz")).setLevel(Level.ERROR);

</sxh>

  1. Il suffit de changer le fichier de propriété qui les contient. Il faut juste paramétrer slf4j pour scanner son fichier de propriété.
  1. Il semble possible de le faire en utilisant log4j directement (ou le framework qui implémente les logs), si c'est le framework qu'on utilise.

Log4j 1.2

Welcome to Apache log4j, a logging library for Java.

Logback

Logback is intended as a successor to the popular log4j project, picking up where log4j leaves off.

Autres remarques : Log4j 2 - Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture.

java.util.logging

Framework standard, embarqué dans les JRE

Concepts généraux à retenir

Les loggers enfant héritent des propriétés (loglevel et appenders) du rootLogger
Un appender défini dans un logger s'ajoute à ou aux appenders déjà définis dans les loggers de la hiérarchie mère.
techniques/slf4j_log4j_lockback_et_java.util.logging.txt · Dernière modification: 2018/02/15 19:50 (modification externe)