0

Should I use a static final or static logger?

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

versus

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

Remark: a simular question is available, but only discusses the static part.

4

1 回答 1

1

I'd make it final. Generally if I know a variable is final then I mark it as such. It helps make the code easier to understand (as you don't have to search through for unexpected side effects) and stops you making silly mistakes by overwriting it.

于 2013-09-27T09:10:01.717 回答