Search in sources :

Example 1 with Log4jOverridableConfigurer

use of org.finra.herd.dao.Log4jOverridableConfigurer in project herd by FINRAOS.

the class DaoEnvTestSpringModuleConfig method log4jConfigurer.

/**
 * The Log4J configuration used by JUnits. It is defined in the DAO tier so all tiers that extend it can take advantage of it.
 * <p/>
 * IMPORTANT: Ensure this method is static since the returned Log4jOverridableConfigurer is a bean factory post processor (BFPP). If it weren't static,
 * autowiring and injection on this @Configuration class won't work due to lifecycle issues. See "Bootstrapping" comment in @Bean annotation for more
 * details.
 *
 * @return the Log4J overridable configurer.
 */
@Bean
public static Log4jOverridableConfigurer log4jConfigurer() {
    Log4jOverridableConfigurer log4jConfigurer = new Log4jOverridableConfigurer();
    log4jConfigurer.setDefaultResourceLocation(TEST_LOG4J_CONFIG_RESOURCE_LOCATION);
    log4jConfigurer.setOverrideResourceLocation("non_existent_override_location");
    return log4jConfigurer;
}
Also used : Log4jOverridableConfigurer(org.finra.herd.dao.Log4jOverridableConfigurer) Bean(org.springframework.context.annotation.Bean)

Example 2 with Log4jOverridableConfigurer

use of org.finra.herd.dao.Log4jOverridableConfigurer in project herd by FINRAOS.

the class AppSpringModuleConfig method log4jConfigurer.

/**
 * The Log4J overridable configurer that will handle our Log4J initialization for the herd application.
 * <p/>
 * IMPORTANT: Ensure this method is static since the returned Log4jOverridableConfigurer is a bean factory post processor (BFPP). If it weren't static,
 * autowiring and injection on this @Configuration class won't work due to lifecycle issues. See "Bootstrapping" comment in @Bean annotation for more
 * details.
 *
 * @return the Log4J overridable configurer.
 */
@Bean
public static Log4jOverridableConfigurer log4jConfigurer() {
    // Access the environment using the application context holder since we're in a static method that doesn't have access to the environment in any
    // other way.
    Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment();
    // Create the Log4J configurer.
    Log4jOverridableConfigurer log4jConfigurer = new Log4jOverridableConfigurer();
    // This is the primary database override location (if present). An entry needs to be present in the database at application startup for this
    // configuration to be used.
    log4jConfigurer.setDataSource(DaoSpringModuleConfig.getHerdDataSource());
    log4jConfigurer.setTableName(ConfigurationEntity.TABLE_NAME);
    log4jConfigurer.setSelectColumn(ConfigurationEntity.COLUMN_VALUE_CLOB);
    log4jConfigurer.setWhereColumn(ConfigurationEntity.COLUMN_KEY);
    log4jConfigurer.setWhereValue(ConfigurationValue.LOG4J_OVERRIDE_CONFIGURATION.getKey());
    // This is the secondary override location (if present and if the primary location isn't present). This resource needs to be present at application
    // startup for this configuration to be used.
    log4jConfigurer.setOverrideResourceLocation(ConfigurationHelper.getProperty(ConfigurationValue.LOG4J_OVERRIDE_RESOURCE_LOCATION, environment));
    // This is the default fallback location which is bundled in the WAR and should always be present in case the override locations aren't present.
    // Note that the herd-log4j.xml file must be in the herd-war project so it is accessible on the classpath as a file. Placing it within another
    // project's JAR will result in the resource not being found as a "file".
    log4jConfigurer.setDefaultResourceLocation("classpath:herd-log4j.xml");
    // Return the Log4J configurer.
    return log4jConfigurer;
}
Also used : Log4jOverridableConfigurer(org.finra.herd.dao.Log4jOverridableConfigurer) Environment(org.springframework.core.env.Environment) Bean(org.springframework.context.annotation.Bean)

Example 3 with Log4jOverridableConfigurer

use of org.finra.herd.dao.Log4jOverridableConfigurer in project herd by FINRAOS.

the class DataBridgeEnvTestSpringModuleConfig method log4jConfigurer.

@Bean
public static Log4jOverridableConfigurer log4jConfigurer() {
    Log4jOverridableConfigurer log4jConfigurer = new Log4jOverridableConfigurer();
    log4jConfigurer.setDefaultResourceLocation(TEST_LOG4J_CONFIG_RESOURCE_LOCATION);
    log4jConfigurer.setOverrideResourceLocation("non_existent_override_location");
    return log4jConfigurer;
}
Also used : Log4jOverridableConfigurer(org.finra.herd.dao.Log4jOverridableConfigurer) Bean(org.springframework.context.annotation.Bean)

Aggregations

Log4jOverridableConfigurer (org.finra.herd.dao.Log4jOverridableConfigurer)3 Bean (org.springframework.context.annotation.Bean)3 Environment (org.springframework.core.env.Environment)1