当前位置: 首页>>代码示例>>Java>>正文


Java DefaultConfiguration类代码示例

本文整理汇总了Java中org.apache.logging.log4j.core.config.DefaultConfiguration的典型用法代码示例。如果您正苦于以下问题:Java DefaultConfiguration类的具体用法?Java DefaultConfiguration怎么用?Java DefaultConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultConfiguration类属于org.apache.logging.log4j.core.config包,在下文中一共展示了DefaultConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createLayout

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
public static PatternLayout createLayout(String logFormat) throws ReflectiveOperationException {
    try {
        Method builder = PatternLayout.class
                .getDeclaredMethod("createLayout", String.class, Configuration.class, RegexReplacement.class
                        , String.class, String.class);

        return (PatternLayout) builder.invoke(null, logFormat, new DefaultConfiguration(), null
                , Charset.defaultCharset().name(), "true");
    } catch (NoSuchMethodException methodEx) {
        return PatternLayout.newBuilder()
                .withCharset(Charset.defaultCharset())
                .withPattern(logFormat)
                .withConfiguration(new DefaultConfiguration())
                .withAlwaysWriteExceptions(true)
                .build();
    }
}
 
开发者ID:games647,项目名称:ColorConsole,代码行数:18,代码来源:CommonLogInstaller.java

示例2: setupClass

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@BeforeClass
public static void setupClass() {

    final Configuration config = ((LoggerContext)LogManager.getContext()).getConfiguration();
    if (!DefaultConfiguration.DEFAULT_NAME.equals(config.getName())) {
        System.out.println("Configuration was " + config.getName());
        ((LoggerContext)LogManager.getContext()).start(new DefaultConfiguration());
    }

    for (int i=0; i < WARMUP; ++i) {
        overhead();
    }
    System.gc();
    final Timer timer = new Timer("Setup", LOOP_CNT);
    timer.start();
    for (int i=0; i < (LOOP_CNT / 150); ++i) {
        overhead();
    }
    timer.stop();
    maxTime = timer.getElapsedNanoTime();
    System.gc();
    System.out.println(timer.toString());
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:24,代码来源:SimplePerfTest.java

示例3: setUp

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
protected void setUp(final String tableName, final String configFileName) throws SQLException {
    this.connection = this.newConnection();
    final Statement statement = this.connection.createStatement();
    try {
        statement.executeUpdate(this.toCreateTableSqlString(tableName));
    } finally {
        statement.close();
    }
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
            "org/apache/logging/log4j/core/appender/db/jdbc/" + configFileName);
    final LoggerContext context = (LoggerContext) LogManager.getContext(false);
    if (context.getConfiguration() instanceof DefaultConfiguration) {
        context.reconfigure();
    }
    StatusLogger.getLogger().reset();
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:17,代码来源:AbstractJdbcAppenderTest.java

示例4: setup

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@Setup
public void setup() throws Exception {
    connectionHSQLDB = getConnectionHSQLDB();
    connectionH2 = getConnectionH2();
    createTable(connectionHSQLDB, toCreateTableSqlStringHQLDB("fmLogEntry"));
    createTable(connectionH2, toCreateTableSqlStringH2("fmLogEntry"));

    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "log4j2-jdbc-appender.xml");
    final LoggerContext context = LoggerContext.getContext(false);
    if (context.getConfiguration() instanceof DefaultConfiguration) {
        context.reconfigure();
    }
    StatusLogger.getLogger().reset();
    loggerH2 = LogManager.getLogger("H2Logger");
    loggerHSQLDB = LogManager.getLogger("HSQLDBLogger");
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:JdbcAppenderBenchmark.java

示例5: setupClass

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@BeforeClass
  public static void setupClass() {

final Configuration config = LoggerContext.getContext().getConfiguration();

if (!DefaultConfiguration.DEFAULT_NAME.equals(config.getName())) {
	System.out.println("Configuration was " + config.getName());
	LoggerContext.getContext().start(new DefaultConfiguration());
}

      for (int i=0; i < WARMUP; ++i) {
          overhead();
      }
      System.gc();
      final Timer timer = new Timer("Setup", LOOP_CNT);
      timer.start();
      for (int i=0; i < (LOOP_CNT / 150); ++i) {
          overhead();
      }
      timer.stop();
      maxTime = timer.getElapsedNanoTime();
      System.gc();
      System.out.println(timer.toString());
  }
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:25,代码来源:SimplePerfTest.java

示例6: testSelectFilesToDelete2

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testSelectFilesToDelete2() {
    final Configuration config = new DefaultConfiguration();
    config.initialize(); // creates the ScriptManager

    final List<PathWithAttributes> pathList = new ArrayList<>();
    pathList.add(new PathWithAttributes(Paths.get("/path/1"), new DummyFileAttributes()));
    pathList.add(new PathWithAttributes(Paths.get("/path/2"), new DummyFileAttributes()));
    pathList.add(new PathWithAttributes(Paths.get("/path/3"), new DummyFileAttributes()));

    final String scriptText = "pathList.remove(1);" //
            + "pathList;";
    final Script script = new Script("test", "javascript", scriptText);
    final ScriptCondition condition = new ScriptCondition(script, config);
    final Path base = Paths.get("baseDirectory");
    final List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
    assertSame(result, pathList);
    assertEquals(2, result.size());
    assertEquals(Paths.get("/path/1"), result.get(0).getPath());
    assertEquals(Paths.get("/path/3"), result.get(1).getPath());
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:22,代码来源:ScriptConditionTest.java

示例7: getConfiguration

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@Override
public Configuration getConfiguration(LoggerContext loggerContext, ConfigurationSource source) {
    if (source != null && source != ConfigurationSource.NULL_SOURCE) {
        if (LoggingSystem.get(loggerContext.getClass().getClassLoader()) != null) {
            return new DefaultConfiguration();
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:logging-log4j-boot,代码行数:10,代码来源:PrebootConfigurationFactory.java

示例8: loadLogAppender

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
private boolean loadLogAppender()
{
	Logger log = (Logger)LogManager.getRootLogger();
	for(Appender appender : log.getAppenders().values())
	{
		if(appender instanceof RConsoleAppender)
			log.removeAppender(appender);
	}
	
	mAppender = new RConsoleAppender(new DefaultConfiguration());
	mAppender.start();
	log.addAppender(mAppender);
	
	return true;
}
 
开发者ID:Schmoller,项目名称:BetterRCon,代码行数:16,代码来源:BetterRCon.java

示例9: testReconfiguration

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testReconfiguration() throws Exception {
    final Configuration cfg = ctx.getConfiguration();
    assertNotNull("No configuration", cfg);
    assertTrue("Not set to default configuration", cfg instanceof DefaultConfiguration);
    final File file = new File(CONFIG);
    LoggerContext loggerContext = (LoggerContext) LogManager.getContext(null, false, file.toURI());
    assertNotNull("No Logger Context", loggerContext);
    final Configuration newConfig = loggerContext.getConfiguration();
    assertTrue("Configuration not reset", cfg != newConfig);
    assertTrue("Reconfiguration failed", newConfig instanceof XMLConfiguration);
    ctx = (LoggerContext) LogManager.getContext(false);
    final Configuration sameConfig = ctx.getConfiguration();
    assertTrue("Configuration should not have been reset", newConfig == sameConfig);
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:16,代码来源:LateConfigTest.java

示例10: setUp

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
public void setUp(final String configFileName) throws SQLException {
    this.connection = this.setUpConnection();

    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
            "org/apache/logging/log4j/core/appender/db/jpa/" + configFileName);
    final LoggerContext context = (LoggerContext) LogManager.getContext(false);
    if (context.getConfiguration() instanceof DefaultConfiguration) {
        context.reconfigure();
    }
    StatusLogger.getLogger().reset();
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:12,代码来源:AbstractJpaAppenderTest.java

示例11: addFileAppender

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
public static void addFileAppender(String filename) {
    if (instance == null) {
        LOGGER.error("CustomFileAppender hasn't been initalized, ignoring output "
                     + filename);
        return;
    }

    final AbstractOutputStreamAppender<? extends OutputStreamManager> appender;
    if (mmap_appender)
        appender = MemoryMappedFileAppender.createAppender(filename,
                                                           "false", filename,
                                                           "false", "8192", "false",
                                                           instance.getLayout(),
                                                           instance.getFilter(),
                                                           "false", "false",
                                                           new DefaultConfiguration());
    else
        appender = FileAppender.createAppender(filename,
                                               "false", "false",
                                               filename,
                                               "false", "false",
                                               "true", "8192",
                                               instance.getLayout(),
                                               instance.getFilter(),
                                               "false", "false",
                                               new DefaultConfiguration());

    LOGGER.info("registering custom logfile '{}'", appender);
    instance.appenders.add(appender);
}
 
开发者ID:neurord,项目名称:stochdiff,代码行数:31,代码来源:CustomFileAppender.java

示例12: log

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
protected String log(String pattern, MuleMessage message) {
    logger.info(message);
    assertThat(testLogAppender.getEvents().size(), is(1));
    Configuration configuration = new DefaultConfiguration();
    configuration.getPluginPackages().add(CONVERTER_PACKAGE);
    PatternLayout layout = PatternLayout.createLayout(pattern, configuration, null, null, true, false, null, null);
    return layout.toSerializable(testLogAppender.getEvents().iterator().next());
}
 
开发者ID:greenbird,项目名称:mule-access-log,代码行数:9,代码来源:AccessLogConverterTestBase.java

示例13: createLayout_normal_combinedPatternUsed

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@Test
public void createLayout_normal_combinedPatternUsed() {
    DefaultConfiguration configuration = new DefaultConfiguration();
    configuration.getPluginPackages().add(AbstractAccessLogConverter.class.getPackage().getName());
    Layout layout = CombinedAccessLogPatternLayout.createLayout(null, configuration, null, false, false, null, null);
    PatternLayout patternLayout = (PatternLayout) layout;
    assertThat(patternLayout.getConversionPattern(), is(CombinedAccessLogPatternLayout.PATTERN));
}
 
开发者ID:greenbird,项目名称:mule-access-log,代码行数:9,代码来源:CombinedAccessLogPatternLayoutTest.java

示例14: createLayout_normal_commonLogPatternUsed

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@Test
public void createLayout_normal_commonLogPatternUsed() {
    DefaultConfiguration configuration = new DefaultConfiguration();
    configuration.getPluginPackages().add(AbstractAccessLogConverter.class.getPackage().getName());
    Layout layout = CommonAccessLogPatternLayout.createLayout(null, configuration, null, false, false, null, null);
    PatternLayout patternLayout = (PatternLayout) layout;
    assertThat(patternLayout.getConversionPattern(), is(CommonAccessLogPatternLayout.PATTERN));
}
 
开发者ID:greenbird,项目名称:mule-access-log,代码行数:9,代码来源:CommonAccessLogPatternLayoutTest.java

示例15: setup

import org.apache.logging.log4j.core.config.DefaultConfiguration; //导入依赖的package包/类
@Setup
public void setup() throws Exception {
    connectionHSQLDB = getConnectionHSQLDB();
    connectionH2 = getConnectionH2();

    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "log4j2-jpa-appender.xml");
    final LoggerContext context = LoggerContext.getContext(false);
    if (context.getConfiguration() instanceof DefaultConfiguration) {
        context.reconfigure();
    }
    StatusLogger.getLogger().reset();
    loggerH2 = LogManager.getLogger("H2Logger");
    loggerHSQLDB = LogManager.getLogger("HSQLDBLogger");
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:15,代码来源:JpaAppenderBenchmark.java


注:本文中的org.apache.logging.log4j.core.config.DefaultConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。