public class Clogr extends Object
Csar
.
Clogr is not yet another logging facade. Rather Clogr facilitates access to SLF4J loggers; while improving SLF4J logging configuration, allowing various
compartmentalized log settings. The LoggingConcern
is accessed using Csar's concern registration mechanism. The primary logging access method
getLoggingConcern()
will return the logging concern registered with Csar. The default, unconfigured state will still merely delegate the
configured SLF4J logger factory, exactly as could be done dynamically directly from SLF4J. The benefit is that multiple logging configurations can separately
be compartmentalized using Csar, and code that accesses loggers via Clogr will be routed to use the correct log configuration automatically.
Moreover classes needing access to a logger may implement Clogged
for simplified retrieval of an SLF4J logger.
Csar
Constructor and Description |
---|
Clogr() |
Modifier and Type | Method and Description |
---|---|
static Optional<LoggingConcern> |
getDefaultLoggingConcern()
Returns the default logging concern.
|
static org.slf4j.Logger |
getLogger(Class<?> contextClass)
Returns an appropriate logger for the current context.
|
static LoggingConcern |
getLoggingConcern()
Returns the configured logging concern for the current context.
|
static Optional<LoggingConcern> |
setDefaultLoggingConcern(LoggingConcern loggingConcern)
Sets the default logging concern.
|
public static Optional<LoggingConcern> getDefaultLoggingConcern()
Csar.getDefaultConcern(Class)
public static Optional<LoggingConcern> setDefaultLoggingConcern(@Nonnull LoggingConcern loggingConcern)
loggingConcern
- The default logging concern to set.null
if there was no previous concern.NullPointerException
- if the given concern is null
.Csar.registerDefaultConcern(Class, Concern)
@Nonnull public static LoggingConcern getLoggingConcern()
If no logging concern is registered for the current context, and no default logging concern is registered, a default logging concern instance will be
returned that retrieves loggers with the equivalent of calling LoggerFactory.getLogger(Class)
.
Csar.getConcern(Class)
,
LoggingConcern.DEFAULT
@Nonnull public static org.slf4j.Logger getLogger(@Nonnull Class<?> contextClass)
This is a convenience method that requests a logger from the current context logging concern.
contextClass
- The context for which logging is to be performed.NullPointerException
- if the given context class is null
.getLoggingConcern()
,
LoggingConcern.getLogger(Class)
Copyright © 2016 GlobalMentor, Inc.. All rights reserved.