Z
Z
Zadavatel_Voprosov2018-12-05 19:35:34
Java
Zadavatel_Voprosov, 2018-12-05 19:35:34

What is the correct way to make (initialize) a logger in Java?

Hello everyone! I'm making a plug-in for something in Java.... And I need to figure out how to make Logger (java.util.logging) better and more correctly?
On different resources (namely Habr, GitHub and my "mega" research) I saw a small bunch of ways:
1) It seems that it did not work for me ... But I need to double-check (Oh, yes. I use IntellijIdea) . Taken from habr .

private static Logger log = Logger.getLogger(SomeClass.class.getName());

2) Found in the sources of the most popular plugin (it is also essential; Taken from GitHub):
private static final Logger logger = Logger.getLogger(SomeClass.class.getCanonicalName());

2) My "best" and "great" way (which is probably the worst :D) :
private static final Logger logger = Logger.getLogger("");
(just empty, that's the best thing, isn't it?) (SARK!1)

Can you tell me which is better (for a cookie.png) ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2018-12-05
@Zadavatel_Voprosov

Any of these.
https://projectlombok.org/features/log
I am using @Log4j

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question