Avoid use of Commons Logging in LoggingCacheErrorHandler public API
At present, creating LoggingCacheErrorHandler with custom logger requires use of Commons Logging API, as the appropriate constructor expects org.apache.commons.logging.Log instance. As Commons Logging is rarely the logging framework of choice in applications these days, interaction with its API might not be desirable. This commit adds LoggingCacheErrorHandler constructor that accepts logger name and thus avoids leaking out any details about the underlying logging framework.
This commit is contained in:
committed by
Juergen Hoeller
parent
182ba4ac29
commit
fb291379e4
@@ -77,6 +77,19 @@ public class LoggingCacheErrorHandler implements CacheErrorHandler {
|
||||
this.logStackTraces = logStackTraces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@code LoggingCacheErrorHandler} that uses the supplied
|
||||
* {@code loggerName} and {@code logStackTraces} flag.
|
||||
* @param loggerName the logger name to use
|
||||
* @param logStackTraces whether to log stack traces
|
||||
* @since 5.3.24
|
||||
*/
|
||||
public LoggingCacheErrorHandler(String loggerName, boolean logStackTraces) {
|
||||
Assert.notNull(loggerName, "'loggerName' must not be null");
|
||||
this.logger = LogFactory.getLog(loggerName);
|
||||
this.logStackTraces = logStackTraces;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handleCacheGetError(RuntimeException exception, Cache cache, Object key) {
|
||||
|
||||
Reference in New Issue
Block a user