Sì, dovresti. L'utilizzo di una facciata di registrazione come SLF4J ti offre flessibilità senza gravare sui tuoi utenti con un particolare framework di registrazione.
Authors of widely-distributed components and libraries may code against the SLF4J interface in order to avoid imposing an logging framework on the end-user of the component or library. Thus, the end-user may choose the desired logging framework at deployment time by inserting the corresponding slf4j binding on the classpath, which may be changed later by replacing an existing binding with another on the class path and restarting the application. This approach has proven to be simple and very robust.
Inoltre, se i tuoi utenti non includono un jar SLF4J (dalla guida per l'utente ):
As of SLF4J version 1.6.0, if no binding is found on the class path, then slf4j-api will default to a no-operation implementation discarding all log requests.
Se sei preoccupato per le implicazioni di rendimento della registrazione, controlla questa voce delle FAQ su SLF4J . L'idea è di fornire parametri per registrare le dichiarazioni invece di aggiungerle a una stringa inline:
The following two lines will yield the exact same output. However, the second form will outperform the first form by a factor of at least 30, in case of a disabled logging statement.
logger.debug("The new entry is "+entry+".");
logger.debug("The new entry is {}.", entry);
SLF4J è un'altra facciata di registrazione?
SLF4J is conceptually very similar to JCL. As such, it can be thought of as yet another logging facade. However, SLF4J is much simpler in design and arguably more robust. In a nutshell, SLF4J avoid the class loader issues that plague [Jakarta Commons Logging].