Skip to content

What is the alternative for LOGGER.entering() and LOGGER.exiting() from Java logger to log4j2 using slf4j #2083

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

You must be logged in to vote

The equivalents of JUL's Logger#entering(String, String, Object[]) and Logger#exiting(String, String, Object) are:

Basically these allow you to replace:

private static final java.util.logging.Logger logger = ...

public String computeFoo(String param1, int param2) {
    logger.entering("org.example.MyClass", "computeFoo", new Object[] {param1, param2});
    // do something

    //
   logger.exiting("org.example.MyClass", "computeFoo", result);
   return result;

with:

private static final org.apache.logging.log4j.Logger logger = ...

public String computeFoo(String param1, int param2) {
    logger.traceEntry(null, new Object[] {param1, param2});
    /…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@ppkarwasz
Comment options

@mehulparmariitr
Comment options

@ppkarwasz
Comment options

Answer selected by mehulparmariitr
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
2 participants