Is there a log4j or commons extension or other logging framework designed for Java 5 or higher?

Java 5 introduced many features that can lead to fewer logging operators, such as a variable number of arguments and printf. This can facilitate the entire message building code that occurs when something is logged in, as well as the surrounding if.

For example, instead of writing:

if (log.isDebugEnabled()
{
    log.debug("User id: "+uid+", Request id:"
    + rid +", Client IP: "+ip+" blah blah blah");
}

I would like to write:

log.debug("User id: %s, Request id: %s, Client IP: %s blah blah blah",
uid, rid, ip);

or something like that.

Do you know a logging framework or extension to a logging framework that can help with this?

+3
source share
3 answers

Log5j - , .

+3

Java (SLF4J)

Java (SLF4J) API . SLF4J API, .

API SLF4J , JDK 1.4, log4j logback. MDC.

:

logger.info("{} {}!", "Hello", "world");

", !". .

+2

-.

+1

Source: https://habr.com/ru/post/1703418/


All Articles