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
FieldsModifier and TypeFieldDescriptionprivate ApplicationContextSpring application context.private ResourceLogging configuration resource.private ResourceURL to the fallback logback configuration found in the classpath.private StringOptional name of a property to populate into theLoggerContext.private ch.qos.logback.classic.LoggerContextLogback logger context.private ch.qos.logback.core.status.StatusManagerLogger used to log messages without relying on the logging system to be full initialized. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThis method checks to ensure that the component ID is not null.protected voiddoReload()Performs the actual reload.Get the serviceable component that this service supports.protected voidAdd the "home" property from the Spring application context to the logger context.protected voidReads and loads in a new logging configuration.protected voidloadLoggingConfiguration(InputStream loggingConfig) Loads a logging configuration in to the active logger context.voidsetApplicationContext(ApplicationContext context) voidsetFallbackConfiguration(Resource fallback) Set a resource to use as a fallback configuration if the primary is unavailable.voidsetHomePropertyName(String name) Set name of a property to load intoLoggerContext.voidsetLoggingConfiguration(Resource configuration) Sets the logging configuration.protected booleanCalled by theAbstractReloadableService<T>.ServiceReloadTaskto 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, setReloadTaskTimerMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getIdMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitializedMethods 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:
setApplicationContextin 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, aServiceExceptionis 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:
getServiceableComponentin 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:
doInitializein classAbstractReloadableService<Object>- Throws:
ComponentInitializationException- thrown if there is a problem initializing the component
-
shouldReload
protected boolean shouldReload()Called by theAbstractReloadableService<T>.ServiceReloadTaskto 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:
shouldReloadin 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:
doReloadin 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.