@Test
public void testLog4JDbWithRefreshInterval() throws Exception
{

    Path configPath = getRandomLog4jConfigPath();
    Path outputPath = getRandomLog4jOutputPath();
    String configKey = null;
    try
    {
        // Create a random configuration key to use when inserting the Log4J configuration into the database.
        configKey = ConfigurationValue.LOG4J_OVERRIDE_CONFIGURATION.getKey() + UUID.randomUUID().toString().substring(0, 5);
        // Insert the standard JUnit Log4J configuration that won't create an output file into the database using the CLOB column.
        // We will use a monitoring interval of 1 second to ensure the watch dog thread gets executed.
        insertDbLog4JConfigurationFromResourceLocation(DaoEnvTestSpringModuleConfig.TEST_LOG4J_CONFIG_RESOURCE_LOCATION, 1, outputPath,
            ConfigurationEntity.COLUMN_VALUE_CLOB, configKey);
        // Shutdown the previously configured logging so we can reinitialize it below.
        loggingHelper.shutdownLogging();
        // Initialize Log4J with a refresh interval of 1/2 second. This will cause Log4J to check for configuration updates every second.
        Log4jOverridableConfigurer log4jConfigurer = getLog4jOverridableConfigurerForDb(configKey);
        log4jConfigurer.postProcessBeforeInitialization(null, null);
        // First ensure that the Log4J output file doesn't exist.
        assertTrue("Log4J output file exists, but shouldn't.", Files.notExists(outputPath));
        // Update the Log4J configuration with one that will create a log file.
        updateDbLog4JConfigurationFromResourceLocation(LOG4J_CONFIG_FILENAME, outputPath, ConfigurationEntity.COLUMN_VALUE_CLOB, configKey);
        // Sleep 3 seconds which will give our watch dog thread and Log4J a chance to read the new configuration file which should create an output file.
        Thread.sleep(3000);
        // Ensure that the Log4J output file now exists.
        assertTrue("Log4J output file doesn't exist, but should.", Files.exists(outputPath));
    }
    finally
    {
        cleanup(configPath, outputPath);
        deleteDbLog4JConfiguration(configKey);
    }
}