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 I really appreciate if anybody knows another best alternative ways to declare looger variable.
I vote for 3
It’s
finalsince you don’t change it and it’s in uppercase since it’s a constant.