Class LogbackLoggingService
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.shared.service.AbstractReloadableService<Object>
net.shibboleth.shared.service.impl.LogbackLoggingService
- All Implemented Interfaces:
Component
,DestructableComponent
,IdentifiableComponent
,IdentifiedComponent
,InitializableComponent
,UnmodifiableComponent
,LoggingService
,ReloadableService<Object>
,Aware
,ApplicationContextAware
public class LogbackLoggingService
extends AbstractReloadableService<Object>
implements LoggingService, ApplicationContextAware
Simple
LoggingService
that watches for logback configuration file changes
and reloads the file when a change occurs.- Since:
- 9.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class net.shibboleth.shared.service.AbstractReloadableService
AbstractReloadableService.ServiceReloadTask
-
Field Summary
Modifier and TypeFieldDescriptionprivate ApplicationContext
Spring application context.private Resource
Logging configuration resource.private Resource
URL to the fallback logback configuration found in the classpath.private String
Optional name of a property to populate into theLoggerContext
.private ch.qos.logback.classic.LoggerContext
Logback logger context.private ch.qos.logback.core.status.StatusManager
Logger used to log messages without relying on the logging system to be full initialized. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
This method checks to ensure that the component ID is not null.protected void
doReload()
Performs the actual reload.Get the serviceable component that this service supports.protected void
Add the "home" property from the Spring application context to the logger context.protected void
Reads and loads in a new logging configuration.protected void
loadLoggingConfiguration
(InputStream loggingConfig) Loads a logging configuration in to the active logger context.void
setApplicationContext
(ApplicationContext context) void
setFallbackConfiguration
(Resource fallback) Set a resource to use as a fallback configuration if the primary is unavailable.void
setHomePropertyName
(String name) Set name of a property to load intoLoggerContext
.void
setLoggingConfiguration
(Resource configuration) Sets the logging configuration.protected boolean
Called by theAbstractReloadableService<T>.ServiceReloadTask
to determine if the service should be reloaded.Methods inherited from class net.shibboleth.shared.service.AbstractReloadableService
doDestroy, getLastReloadAttemptInstant, getLastSuccessfulReloadInstant, getLogPrefix, getReloadCheckDelay, getReloadFailureCause, getReloadTaskTimer, isFailFast, reload, setFailFast, setReloadCheckDelay, setReloadTaskTimer
Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setId
Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException
Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, initialize, isDestroyed, isInitialized
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getId
Methods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
Methods inherited from interface net.shibboleth.shared.service.ReloadableService
getLastReloadAttemptInstant, getLastSuccessfulReloadInstant, getReloadFailureCause, reload
-
Field Details
-
loggerContext
Logback logger context. -
statusManager
Logger used to log messages without relying on the logging system to be full initialized. -
fallbackConfiguration
URL to the fallback logback configuration found in the classpath. -
configurationResource
Logging configuration resource. -
homePropertyName
Optional name of a property to populate into theLoggerContext
. -
applicationContext
Spring application context.
-
-
Constructor Details
-
LogbackLoggingService
public LogbackLoggingService()
-
-
Method Details
-
setHomePropertyName
Set name of a property to load intoLoggerContext
.- Parameters:
name
- property name
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
-
getServiceableComponent
Get the serviceable component that this service supports. If the component hasn't been successfully loaded yet or if this service does not support a ServiceableComponent, aServiceException
is raised.On a non-null value, the returned component will be pinned and MUST be closed. This can be done by exploiting the fact that a ServiceableComponent implements
. This service does not support a ServiceableComponent, so return null.AutoCloseable
- Specified by:
getServiceableComponent
in interfaceReloadableService<Object>
- Returns:
- the component, if appropriate.
-
doInitialize
This method checks to ensure that the component ID is not null. Performs the initialization of the component. This method is executed within the lock on the object being initialized. The default implementation of this method is a no-op.- Overrides:
doInitialize
in classAbstractReloadableService<Object>
- Throws:
ComponentInitializationException
- thrown if there is a problem initializing the component
-
shouldReload
protected boolean shouldReload()Called by theAbstractReloadableService<T>.ServiceReloadTask
to determine if the service should be reloaded.No lock is held when this method is called, so any locking needed should be handled internally.
- Specified by:
shouldReload
in classAbstractReloadableService<Object>
- Returns:
- true iff the service should be reloaded
-
doReload
protected void doReload()Performs the actual reload.No lock is held when this method is called, so any locking needed should be handled internally.
- Overrides:
doReload
in classAbstractReloadableService<Object>
-
loadLoggingConfiguration
protected void loadLoggingConfiguration()Reads and loads in a new logging configuration.- Throws:
ServiceException
- thrown if there is a problem loading the logging configuration
-
loadLoggingConfiguration
Loads a logging configuration in to the active logger context. Error messages are printed out to the status manager.- Parameters:
loggingConfig
- logging configuration file- Throws:
ServiceException
- thrown is there is a problem loading the logging configuration
-
loadHomeProperty
protected void loadHomeProperty()Add the "home" property from the Spring application context to the logger context.This is principally to allow a defaulted value of this property to be referenced within the logging configuration itself as a location.