Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Redirecting all logging (also from all third party libs) to fabric3 @Monitor

There are 3 options, how this can be achieved:1.

  1. Use the fabric3-monitor-log in you application by embedding it in META-INF/lib (the Fabric3 contribution plugin can do this).

...

  1.  You will then need to exclude commons logging and SLF4J implementations from the transitive dependencies of any libraries you may have.

...

  1.  This is because fabric3-monitor-log replaces those implementations with its own that redirects out to the monitor infrastructure.

...

  1.  This will require a dependency on the Fabric3 SPI package.

...

  1. Create your own redirection, potentially using org.fabric3.spi.monitor.MonitorLocator from the SPI.

...

  1.  You may need to do this if you have a library that uses custom logging. This will require a dependency on the Fabric3 SPI package.

...

  1. Create a component in Fabric3 that is injected with a org.fabric3.api.MonitorChannel using the @Monitor annotation.

...

  1.  This component can then set a singleton or some other mechanism to redirect from third-party logging to Fabric3.

...

  1.  The advantage of this approach is there is no dependency on SPI and you have more control over monitoring - for example,

...

  1.  you can set a custom destination or multiple destinations.

I will write about the third approach:
Usualy on projects I'm using common module, which contains definitions and some common classes. We put the logger impl there.
This common module than needs to be imported in every component. In common, we have these dependencies:

...