use of ch.qos.logback.classic.db.DBAppender in project qpid-broker-j by apache.
the class JDBCLoggerHelper method restartConnectionSourceIfExists.
void restartConnectionSourceIfExists(final Appender appender) {
if (appender instanceof DBAppender) {
final ConnectionSource connectionSource = ((DBAppender) appender).getConnectionSource();
if (connectionSource != null) {
connectionSource.stop();
connectionSource.start();
}
}
}
use of ch.qos.logback.classic.db.DBAppender in project qpid-broker-j by apache.
the class JDBCLoggerHelperTest method restartConnectionSourceIfExists.
@Test
public void restartConnectionSourceIfExists() {
final ConnectionSource connectionSource = mock(ConnectionSource.class);
final DBAppender appender = mock(DBAppender.class);
when(appender.getConnectionSource()).thenReturn(connectionSource);
_jdbcLoggerHelper.restartConnectionSourceIfExists(appender);
verify(connectionSource).stop();
verify(connectionSource).start();
verifyNoMoreInteractions(connectionSource);
}
use of ch.qos.logback.classic.db.DBAppender in project qpid-broker-j by apache.
the class JDBCLoggerHelper method createAppenderInstance.
Appender<ILoggingEvent> createAppenderInstance(final Context context, final ConfiguredObject<?> logger, final JDBCSettings settings) {
try {
final JDBCSettingsDBNameResolver dbNameResolver = new JDBCSettingsDBNameResolver(settings);
final ConnectionSource connectionSource = createConnectionSource(context, logger, settings);
final DBAppender appender = new DBAppender();
appender.setDbNameResolver(dbNameResolver);
appender.setConnectionSource(connectionSource);
appender.setContext(context);
appender.start();
return appender;
} catch (Exception e) {
LOGGER.error("Failed to create appender", e);
throw new IllegalConfigurationException("Cannot create appender");
}
}
Aggregations