Skip to content

Use slf4j over old logging APIs in Maven #337

@digulla

Description

@digulla

Change the code to use slf4j loggers everywhere.

Reasons:

  • We have Mojo code which uses the Mojo logger
  • We have other code which uses a Plexus logger
  • We have code used from both places which would benefit from logging and jumps to hoops to make it happen.

If we used the underlying slf4j logging framework directly, every part of the code could use the same logger type and everyone could ask for a logger (right now, you have to have it injected via Plexus or call getLog() in the Mojo), eliminating the need to get loggers and then pass them around.

Changes: Get a logger using this code at the top of a class which needs logging:

private final Logger LOG = LoggerFactory.getLogger( getClass() );

or using

private static final Logger LOG = LoggerFactory.getLogger( TypeName.class );

Note: The latter is slightly faster but if you forget to replace the type name, the logger will have the wrong name.

Additional advantage: If you enable logger names in the log output, you can find places where some message was logged much more quickly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions