Skip to content

The encapsulated LogUtils utility class has an error printing line numbers, and the output log is the line number in LogUtils #2133

Answered by ppkarwasz
scwlkq asked this question in Q&A
Discussion options

You must be logged in to vote

@scwlkq,

Edit: in the original answer I missed the fact that you are using SLF4J instead of the Log4j API.
I adapted some content to also work with SLF4J.

Both SLF4J and Log4j API create log messages lazily only if the log level is enabled (cf. e.g. Log4j API source code), so you can safely replace:

    public static void trace(Logger logger, Marker marker, String msg, Object arg) {
        if (isTraceEnabled(logger, marker)) {
            logger.trace(marker, msg, arg);
        }
    }

in your code with:

    public static void trace(Logger logger, Marker marker, String msg, Object arg) {
        logger.trace(marker, msg, arg);
    }

Now you have two choices:

  • either inline all call sites…

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
1 reply
@Pil0tXia
Comment options

Comment options

You must be logged in to vote
1 reply
@scwlkq
Comment options

Comment options

You must be logged in to vote
5 replies
@Pil0tXia
Comment options

@ppkarwasz
Comment options

@Pil0tXia
Comment options

@ppkarwasz
Comment options

@Pil0tXia
Comment options

Answer selected by scwlkq
Comment options

You must be logged in to vote
1 reply
@ppkarwasz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #2132 on December 28, 2023 06:33.