Spring Inject Logger by Annotation Example

You may also like...

Subscribe
Notify of
guest
4 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Marcin
Marcin
February 11, 2017 10:50

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
chx
February 15, 2018 13:47

Nice. One question.

private static @Log Logger LOG;

Why has it to be static?

4
0
Would love your thoughts, please comment.x
()
x