Can I get a dummy logger from slf4j? (Think of a null object design pattern.) If so, can anyone give an example? Or will I need to run my own journal if I want to do this?
I hope to write a function line by line
private Logger logger; static Logger nullLogger; static { nullLogger = getMeADummyLogger(); } public Logger getLogger() { return this.logger == null ? nullLogger : this.logger; }
and do not get a NullPointerException on this last line unless a logger is set.
java null-object-pattern slf4j
Michael Kjörling
source share