Spring Inject Logger by Annotation Example

You may also like...

4
Leave a Reply

avatar
2 Comment threads
2 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
MemoryNotFoundchxMarcin Recent comment authors
  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?