Spring Inject Logger by Annotation Example

You may also like...

Leave a Reply

4 Comments on "Spring Inject Logger by Annotation Example"

avatar
  Subscribe  
newest oldest
Notify of
Marcin
Guest
Marcin

Injecting is really nice, but I suggest to add default or null value for LOG field before injection e.g.

class Component {
…. @Log LOG = Logger.NULL_LOGGER;
}

This way component may be easily unit tested and e.g. borrowed to be used in console app.

chx
Guest
chx

Nice. One question.

private static @Log Logger LOG;

Why has it to be static?