Class LoggingCacheErrorHandler
java.lang.Object
org.springframework.cache.interceptor.LoggingCacheErrorHandler
- All Implemented Interfaces:
- CacheErrorHandler
A 
CacheErrorHandler implementation that logs error messages.
Can be used when underlying cache errors should be ignored.
- Since:
- 5.3.16
- Author:
- Adam Ostrožlík, Stephane Nicoll, Vedran Pavic, Sam Brannen
- 
Constructor SummaryConstructorsConstructorDescriptionCreate aLoggingCacheErrorHandlerthat uses the default logging category and does not log stack traces.LoggingCacheErrorHandler(boolean logStackTraces) Create aLoggingCacheErrorHandlerthat uses the default logging category and the suppliedlogStackTracesflag.LoggingCacheErrorHandler(String loggerName, boolean logStackTraces) Create aLoggingCacheErrorHandlerthat uses the suppliedloggerNameandlogStackTracesflag.LoggingCacheErrorHandler(org.apache.commons.logging.Log logger, boolean logStackTraces) Create aLoggingCacheErrorHandlerthat uses the suppliedloggerandlogStackTracesflag.
- 
Method SummaryModifier and TypeMethodDescriptionprotected final org.apache.commons.logging.LogGet the logger for thisLoggingCacheErrorHandler.voidhandleCacheClearError(RuntimeException exception, Cache cache) Handle the given runtime exception thrown by the cache provider when clearing the specifiedCache, possibly rethrowing it as a fatal exception.voidhandleCacheEvictError(RuntimeException exception, Cache cache, Object key) Handle the given runtime exception thrown by the cache provider when clearing an item with the specifiedkey, possibly rethrowing it as a fatal exception.voidhandleCacheGetError(RuntimeException exception, Cache cache, Object key) Handle the given runtime exception thrown by the cache provider when retrieving an item with the specifiedkey, possibly rethrowing it as a fatal exception.voidhandleCachePutError(RuntimeException exception, Cache cache, Object key, @Nullable Object value) Handle the given runtime exception thrown by the cache provider when updating an item with the specifiedkeyandvalue, possibly rethrowing it as a fatal exception.protected final booleanGet thelogStackTracesflag for thisLoggingCacheErrorHandler.protected voidlogCacheError(Supplier<String> messageSupplier, RuntimeException exception) Log the cache error message in the given supplier.
- 
Constructor Details- 
LoggingCacheErrorHandlerpublic LoggingCacheErrorHandler()Create aLoggingCacheErrorHandlerthat uses the default logging category and does not log stack traces.The default logging category is " org.springframework.cache.interceptor.LoggingCacheErrorHandler".
- 
LoggingCacheErrorHandlerpublic LoggingCacheErrorHandler(boolean logStackTraces) Create aLoggingCacheErrorHandlerthat uses the default logging category and the suppliedlogStackTracesflag.The default logging category is " org.springframework.cache.interceptor.LoggingCacheErrorHandler".- Parameters:
- logStackTraces- whether to log stack traces
- Since:
- 5.3.22
 
- 
LoggingCacheErrorHandlerpublic LoggingCacheErrorHandler(org.apache.commons.logging.Log logger, boolean logStackTraces) Create aLoggingCacheErrorHandlerthat uses the suppliedloggerandlogStackTracesflag.- Parameters:
- logger- the logger to use
- logStackTraces- whether to log stack traces
 
- 
LoggingCacheErrorHandlerCreate aLoggingCacheErrorHandlerthat uses the suppliedloggerNameandlogStackTracesflag.- Parameters:
- loggerName- the name of the logger to use. The name will be passed to the underlying logger implementation through Commons Logging, getting interpreted as log category according to the logger's configuration.
- logStackTraces- whether to log stack traces
- Since:
- 5.3.24
- See Also:
 
 
- 
- 
Method Details- 
handleCacheGetErrorDescription copied from interface:CacheErrorHandlerHandle the given runtime exception thrown by the cache provider when retrieving an item with the specifiedkey, possibly rethrowing it as a fatal exception.- Specified by:
- handleCacheGetErrorin interface- CacheErrorHandler
- Parameters:
- exception- the exception thrown by the cache provider
- cache- the cache
- key- the key used to get the item
- See Also:
 
- 
handleCachePutErrorpublic void handleCachePutError(RuntimeException exception, Cache cache, Object key, @Nullable Object value) Description copied from interface:CacheErrorHandlerHandle the given runtime exception thrown by the cache provider when updating an item with the specifiedkeyandvalue, possibly rethrowing it as a fatal exception.- Specified by:
- handleCachePutErrorin interface- CacheErrorHandler
- Parameters:
- exception- the exception thrown by the cache provider
- cache- the cache
- key- the key used to update the item
- value- the value to associate with the key
- See Also:
 
- 
handleCacheEvictErrorDescription copied from interface:CacheErrorHandlerHandle the given runtime exception thrown by the cache provider when clearing an item with the specifiedkey, possibly rethrowing it as a fatal exception.- Specified by:
- handleCacheEvictErrorin interface- CacheErrorHandler
- Parameters:
- exception- the exception thrown by the cache provider
- cache- the cache
- key- the key used to clear the item
 
- 
handleCacheClearErrorDescription copied from interface:CacheErrorHandlerHandle the given runtime exception thrown by the cache provider when clearing the specifiedCache, possibly rethrowing it as a fatal exception.- Specified by:
- handleCacheClearErrorin interface- CacheErrorHandler
- Parameters:
- exception- the exception thrown by the cache provider
- cache- the cache to clear
 
- 
getLoggerprotected final org.apache.commons.logging.Log getLogger()Get the logger for thisLoggingCacheErrorHandler.- Returns:
- the logger
- Since:
- 5.3.22
 
- 
isLogStackTracesprotected final boolean isLogStackTraces()Get thelogStackTracesflag for thisLoggingCacheErrorHandler.- Returns:
- trueif this- LoggingCacheErrorHandlerlogs stack traces
- Since:
- 5.3.22
 
- 
logCacheErrorLog the cache error message in the given supplier.If isLogStackTraces()istrue, the givenexceptionwill be logged as well.The default implementation logs the message as a warning. - Parameters:
- messageSupplier- the message supplier
- exception- the exception thrown by the cache provider
- Since:
- 5.3.22
- See Also:
 
 
-