Spring Inject Logger by Annotation Example

You may also like...

  • 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.