Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is there a recommended idiom for declaring a logger in a class?

0
10 Posted

Is there a recommended idiom for declaring a logger in a class?

0

The following is the recommended logger declaration idiom. It assumes that your logger is a static variable of the class. package some.package; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MyClass { final static Logger logger = LoggerFactory.getLogger(MyClass.class); … etc } Unfortunately, give that the name of the hosting class is part of the logger declaration, the above logger declaration idiom is not is not resistant to cut-and-pasting between classes.

0
10

The following is the recommended logger declaration idiom. For reasons explained above, it is left to the user to determine whether loggers are declared as static variables or not.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123