Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add custom levels to SLF4J?

SLF4J appears to support TRACE, DEBUG, INFO, WARN and ERROR levels out of the box.

Is there a way to add my own custom levels?

like image 466
bacar Avatar asked Aug 30 '12 16:08

bacar


People also ask

What is the default logging level in SLF4J?

Developers just need to include the logging framework dependency in the classpath and SLF4J will utilize it to append the logs. If no logging dependency is provided on the classpath, it will default to a no-operation implementation and nothing gets logged.

What is the advantage of SLF4J?

This is the main purpose of SLF4J (Simple Logging Facade for Java) – a logging abstraction which helps to decouple your application from the underlying logger by allowing it to be plugged in – at runtime. Of course, the flexibility that such an abstraction provides is the main reason to use SLF4J.

Is SLF4J logger safe?

Thus, if your SLF4J provider/binding is slf4j-log4j12. jar, you are safe regarding CVE-2021-44228. If you are using log4j-over-slf4j. jar in conjunction with the SLF4J API, you are safe unless the underlying implementation is log4j 2.

Is SLF4J a facade?

The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction 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.


1 Answers

The levels supported by SLF4J are fixed and cannot be changed. However, SLF4J supports markers allowing infinite flexibility in tagging/categorizing log messages. All printing method in the Logger interface have a variant which takes a Marker as its first argument.

like image 124
Ceki Avatar answered Oct 14 '22 05:10

Ceki