Class LoggingHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.LoggingHandler
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Ordered
,ExpressionCapable
,Orderable
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageHandler
,reactor.core.CoreSubscriber<Message<?>>
MessageHandler implementation that simply logs the Message or its payload depending on the value of the
'shouldLogFullMessage' or SpEL 'logExpression' property.
If logging the payload, and it is assignable to Throwable, it will log the stack
trace. By default, it will log the payload only.
- Since:
- 1.0.1
- Author:
- Mark Fisher, Gary Russell, Artem Bilan, Andriy Kryvtsun
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionLoggingHandler
(String level) Create a LoggingHandler with the given log level (case-insensitive).Create aLoggingHandler
with the given logLoggingHandler.Level
. -
Method Summary
Modifier and TypeMethodDescriptionSubclasses may implement this method to provide component type information.getLevel()
protected void
handleMessageInternal
(Message<?> message) protected void
onInit()
Subclasses may implement this for initialization logic.void
setLevel
(LoggingHandler.Level level) Set the loggingLoggingHandler.Level
to change the behavior at runtime.void
setLogExpression
(Expression expression) Set anExpression
to evaluate a log entry at runtime against the requestMessage
.void
setLogExpressionString
(String expressionString) Set a SpEL expression string to use.void
setLoggerName
(String loggerName) void
setShouldLogFullMessage
(boolean shouldLogFullMessage) Specify whether to log the full Message.Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConvention
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface reactor.core.CoreSubscriber
currentContext
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
LoggingHandler
Create a LoggingHandler with the given log level (case-insensitive).The valid levels are: FATAL, ERROR, WARN, INFO, DEBUG, or TRACE
- Parameters:
level
- The level.- See Also:
-
LoggingHandler
Create aLoggingHandler
with the given logLoggingHandler.Level
.- Parameters:
level
- theLoggingHandler.Level
to use.- Since:
- 4.3
-
-
Method Details
-
setLogExpressionString
Set a SpEL expression string to use.- Parameters:
expressionString
- the SpEL expression string to use.- Since:
- 4.3
- See Also:
-
setLogExpression
Set anExpression
to evaluate a log entry at runtime against the requestMessage
.- Parameters:
expression
- theExpression
to use.- Since:
- 4.3
- See Also:
-
getLevel
- Returns:
- The current logging
LoggingHandler.Level
.
-
setLevel
Set the loggingLoggingHandler.Level
to change the behavior at runtime.- Parameters:
level
- the level.
-
setLoggerName
-
setShouldLogFullMessage
public void setShouldLogFullMessage(boolean shouldLogFullMessage) Specify whether to log the full Message. Otherwise, only the payload will be logged. This value isfalse
by default.- Parameters:
shouldLogFullMessage
- true if the complete message should be logged.
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessageHandlerSupport
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classIntegrationObjectSupport
-
handleMessageInternal
- Specified by:
handleMessageInternal
in classAbstractMessageHandler
-