本文介绍了这是在Java中声明logger变量的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想知道哪种方法是在Java中声明logger变量的最佳方法.以下是一些声明.
I just wantd to know which is the best way declare logger variable in java.Following are some declaration.
1> private static final Logger logger = Logger.getLogger(ServiceImpl.class);
2> private static Logger logger = Logger.getLogger(ServiceImpl.class);
3> private static final Logger LOGGER= Logger.getLogger(ServiceImpl.class);
4> private static Logger LOGGER= Logger.getLogger(ServiceImpl.class);
P.S我真的很感谢,如果有人知道另一种更好的声明looger变量的替代方法.
P.S I really appreciate if anybody knows another best alternative ways to declare looger variable.
推荐答案
我投票赞成 3
private static final Logger LOGGER = Logger.getLogger(ServiceImpl.class);
它是final
,因为您没有更改它,因为它是一个常量,所以它是大写.
It's final
since you don't change it and it's in uppercase since it's a constant.
这篇关于这是在Java中声明logger变量的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!