Search in sources :

Example 6 with DBAppender

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();
        }
    }
}
Also used : ConnectionSource(ch.qos.logback.core.db.ConnectionSource) DBAppender(ch.qos.logback.classic.db.DBAppender)

Example 7 with DBAppender

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);
}
Also used : ConnectionSource(ch.qos.logback.core.db.ConnectionSource) DBAppender(ch.qos.logback.classic.db.DBAppender) Test(org.junit.Test)

Example 8 with DBAppender

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");
    }
}
Also used : ConnectionSource(ch.qos.logback.core.db.ConnectionSource) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) DBAppender(ch.qos.logback.classic.db.DBAppender) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException)

Aggregations

DBAppender (ch.qos.logback.classic.db.DBAppender)8 Test (org.junit.Test)6 Appender (ch.qos.logback.core.Appender)4 ConnectionSource (ch.qos.logback.core.db.ConnectionSource)3 LoggerContext (ch.qos.logback.classic.LoggerContext)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1