Csar Logging Registration (Clogr) simplifies SLF4J logger access while providing compartmentalized logging configurations via Csar.
Quick Start
1. Include Clogr Dependency
Include the appropriate Clogr dependency from Maven. To support Logback, for example, simply add io.clogr:clogr-logback:x.x.x
to your POM which transitively brings in the Logback and SLF4J dependencies as wel. If you merely wish easy logger access, instead add io.clogr:clogr:x.x.x
and configure your SLF4J dependencies as you normally would.
2. Implement Clogged
Implement Clogged
to bring quick and easy logger access to any class.
3. Get a Logger
Acquire an SLF4J Logger
instance via Clogged
—the same logger you would get from a LoggerFactory.getLogger(getClass())
, but easier and with the ability to compartmentalize logging configurations.
4. Use multiple logging configurations
Using Csar (included) you can have the same code running in different threads use different loggers! Clogr's Logback extensions even allow legacy code using LoggerFactory.getLogger(getClass())
to retrieve the correct logger! (Static loggers will not be affected.) The following example assumes you have included the io.clogr:clogr-logback:x.x.x
dependency.
Learn More
You can access an in-depth introduction to Clogr, and learn more about logging in general.