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


Java LogManager.resetConfiguration方法代码示例

本文整理汇总了Java中org.apache.log4j.LogManager.resetConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java LogManager.resetConfiguration方法的具体用法?Java LogManager.resetConfiguration怎么用?Java LogManager.resetConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.log4j.LogManager的用法示例。


在下文中一共展示了LogManager.resetConfiguration方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
/**
 *  Loads the test-specific Log4J configuration and resets the environment.
 */
public void setUp(String propertiesName)
throws Exception
{
    URL config = ClassLoader.getSystemResource(propertiesName);
    assertNotNull("missing configuration: " + propertiesName, config);

    LogManager.resetConfiguration();
    PropertyConfigurator.configure(config);

    localLogger = Logger.getLogger(getClass());

    runId = String.valueOf(System.currentTimeMillis());
    resourceName = "SNSAppenderIntegrationTest-" + runId;
    System.setProperty("SNSAppenderIntegrationTest.resourceName", resourceName);

    localSNSclient = AmazonSNSClientBuilder.defaultClient();
    localSQSclient = AmazonSQSClientBuilder.defaultClient();
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:22,代码来源:SNSAppenderIntegrationTest.java

示例2: initLog

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
/**
 * Initializes Log4j logging.
 *
 * @throws ServerException thrown if Log4j could not be initialized.
 */
protected void initLog() throws ServerException {
  verifyDir(logDir);
  LogManager.resetConfiguration();
  File log4jFile = new File(configDir, name + "-log4j.properties");
  if (log4jFile.exists()) {
    PropertyConfigurator.configureAndWatch(log4jFile.toString(), 10 * 1000); //every 10 secs
    log = LoggerFactory.getLogger(Server.class);
  } else {
    Properties props = new Properties();
    try {
      InputStream is = getResource(DEFAULT_LOG4J_PROPERTIES);
      try {
        props.load(is);
      } finally {
        is.close();
      }
    } catch (IOException ex) {
      throw new ServerException(ServerException.ERROR.S03, DEFAULT_LOG4J_PROPERTIES, ex.getMessage(), ex);
    }
    PropertyConfigurator.configure(props);
    log = LoggerFactory.getLogger(Server.class);
    log.warn("Log4j [{}] configuration file not found, using default configuration from classpath", log4jFile);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:Server.java

示例3: setUp

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
/**
 *  Loads the test-specific Log4J configuration and resets the environment.
 */
public void setUp(String propertiesName, String streamName) throws Exception
{
    URL config = ClassLoader.getSystemResource(propertiesName);
    assertNotNull("missing configuration: " + propertiesName, config);

    LogManager.resetConfiguration();
    PropertyConfigurator.configure(config);

    localLogger = Logger.getLogger(getClass());

    localClient = AmazonKinesisClientBuilder.defaultClient();

    deleteStreamIfExists(streamName);
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:18,代码来源:KinesisAppenderIntegrationTest.java

示例4: setupLogger

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
public static void setupLogger(Config config) throws IOException {

        Layout layout = new PatternLayout("%d{" + DATE_FORMAT + "} %5p: %m%n");

        Appender appender = new DailyRollingFileAppender(
                layout, config.getString("logger.file"), "'.'yyyyMMdd");

        LogManager.resetConfiguration();
        LogManager.getRootLogger().addAppender(new NullAppender());

        logger = Logger.getLogger(LOGGER_NAME);
        logger.addAppender(appender);
        logger.setLevel(Level.toLevel(config.getString("logger.level"), Level.ALL));

        // Workaround for "Bug 745866 - (EDG-45) Possible netty logging config problem"
        InternalLoggerFactory.setDefaultFactory(new InternalLoggerFactory() {
            @Override
            public InternalLogger newInstance(String string) {
                return new NettyInternalLogger();
            }
        });

        Log.logSystemInfo();
        Log.info("Version: " + getAppVersion());
    }
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:26,代码来源:Log.java

示例5: setUp

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
@Before
public void setUp()
{
    LogManager.resetConfiguration();
    LogLog.setQuietMode(true);
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:7,代码来源:TestCloudWatchAppender.java

示例6: setUp

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
/**
 *  Loads the test-specific Log4J configuration and resets the environment.
 */
public void setUp(String propertiesName, String logGroupName) throws Exception
{
    URL config = ClassLoader.getSystemResource(propertiesName);
    assertNotNull("missing configuration: " + propertiesName, config);

    LogManager.resetConfiguration();
    PropertyConfigurator.configure(config);

    localLogger = Logger.getLogger(getClass());

    localClient = AWSLogsClientBuilder.defaultClient();

    deleteLogGroupIfExists(logGroupName);
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:18,代码来源:CloudWatchAppenderIntegrationTest.java

示例7: reload

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
@Override
public Response reload() {
    ApplicationProperties.reload();
    Properties copyToReturn = ApplicationProperties.getProperties();
    configurer.setProperties(copyToReturn);

    filesConfiguration.reload();

    LogManager.resetConfiguration();
    DOMConfigurator.configure("../data/conf/log4j.xml");

    copyToReturn.put("logging-reload-state", "Property reload complete");

    return ResponseBuilder.ok(new TreeMap<>(copyToReturn));
}
 
开发者ID:cerner,项目名称:jwala,代码行数:16,代码来源:AdminServiceRestImpl.java

示例8: configureLog4jFromSystemProperties

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
public static void configureLog4jFromSystemProperties() {
	final String LOGGER_PREFIX = "log4j";
	Properties props = new Properties();

	System.out.println("<Log_level>: DEBUG, WARN, ERROR, FATAL, INFO, TRACE, TRACE_INT, ALL, OFF");
	System.out.print(
			"Type \"-Dlog4j=<Log_level>\" as VM arguments to specify a log level - By default \"debug\" mode is on\n\n");

	// Read the VM argument (e.g. java -Dlog4j=all ...)
	for (String propertyName : System.getProperties().stringPropertyNames()) {

		if (propertyName.startsWith(LOGGER_PREFIX)) {

			/*
			 * take the value on the right of equal sign of VM argument and
			 * store it in "levelName" variable (e.g. java -Dlog4j=all, take
			 * the "all" value and store it in "levelName" variable)
			 */
			String levelName = System.getProperty(propertyName, "");

			Level level = Level.toLevel(levelName); // If the conversion
													// fails, then this
													// method returns DEBUG

			// If a value is assigned to log4j option and this value is not
			// recognized by Level class
			if (!"".equals(levelName) && !levelName.toUpperCase().equals(level.toString())) {
				System.err.print("Skipping unrecognized log4j log level " + levelName + ": -D" + propertyName + "="
						+ levelName + "\n\n");
			} else {
				try {
					InputStream configStream = ParquetStats.class.getClassLoader()
							.getResourceAsStream("log4j.properties");
					props.load(configStream);
					configStream.close();
				} catch (Exception e) {
					System.err.println("Error not laod configuration file");
					System.exit(1);
				}
				props.setProperty("log4j.rootLogger", levelName + ", stdout");
				LogManager.resetConfiguration();
				PropertyConfigurator.configure(props);
			}
		}
	}
}
 
开发者ID:pfratta,项目名称:ParquetUtils,代码行数:47,代码来源:ParquetStats.java

示例9: cleanUp

import org.apache.log4j.LogManager; //导入方法依赖的package包/类
@After
public void cleanUp() {
  System.setErr(originalOut);
  LogManager.resetConfiguration();
  kmsAudit.shutdown();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:7,代码来源:TestKMSAudit.java


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