What is the best way to initialize a registrar in a class?

I have two options for initializing Loggerinside the class.

The first way is to provide an instance Class<?>:

logger = LoggerFactory.getLogger(SignUpController.class);

and the second passes the identifier String(package and class name):

logger = LoggerFactory.getLogger("controller.SignUpController");

Questions:

What is the best way to initialize a logger for a class?
What modifiers should I use? (Access modifiers static, final)

+4
source share
2 answers

I use

public final Logger = LogFactory.getLogger(getClass());

. .

, - , .

+6

private static final Logger logger = LoggerFactory.getLogger(SignUpController.class);

API ( ), , / .

private static final

private:

:

, .

+5

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


All Articles