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


Java StatusLogger类代码示例

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


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

示例1: checkStaticState

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
protected static void checkStaticState() throws Exception {
    MockPageCacheRecycler.ensureAllPagesAreReleased();
    MockBigArrays.ensureAllArraysAreReleased();
    // field cache should NEVER get loaded.
    String[] entries = UninvertingReader.getUninvertedStats();
    assertEquals("fieldcache must never be used, got=" + Arrays.toString(entries), 0, entries.length);

    // ensure no one changed the status logger level on us
    assertThat(StatusLogger.getLogger().getLevel(), equalTo(Level.WARN));
    synchronized (statusData) {
        try {
            // ensure that there are no status logger messages which would indicate a problem with our Log4j usage; we map the
            // StatusData instances to Strings as otherwise their toString output is useless
            assertThat(
                statusData.stream().map(status -> status.getMessage().getFormattedMessage()).collect(Collectors.toList()),
                empty());
        } finally {
            // we clear the list so that status data from other tests do not interfere with tests within the same JVM
            statusData.clear();
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:ESTestCase.java

示例2: main

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
    // some of the libs we depend on hard coded Log4J into the source. So disable their logging
    // to prevent warnings from being printed to the console
    StatusLogger.getLogger().setLevel(Level.OFF);

    if(args.length != 1)
    {
        System.out.println("Usage: java -cp [trails.jar]:[floodgage.jar] [bayou-hostname]");
        return;
    }

    String bayouHostname = args[0];
    SynthesizerBayou_1_1_0 synthesizer = new SynthesizerBayou_1_1_0(bayouHostname, 8080);

    try
    {
        new FloodGage().run(synthesizer, new ViewConsole());
    }
    finally
    {
        System.out.println(""); // so that visually the command prompt on exit is not cluttered by our output
    }
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:25,代码来源:FloodGageMain.java

示例3: tearDown

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
@After
public void tearDown() throws Exception {
  Configurator.shutdown();

  System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  if (this.beforeConfigFileProp != null) {
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
        this.beforeConfigFileProp);
  }
  StatusLogger.getLogger().setLevel(this.beforeLevel);

  LogService.reconfigure();
  assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation())
      .isTrue();

  BasicAppender.clearInstance();

  assertThat(this.systemErrRule.getLog()).isEmpty();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例4: setUp

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  Configurator.shutdown();
  BasicAppender.clearInstance();

  this.beforeConfigFileProp =
      System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  this.beforeLevel = StatusLogger.getLogger().getLevel();

  this.customConfigFile = createConfigFileIn(this.temporaryFolder.getRoot());

  System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
      this.customConfigFile.getAbsolutePath());
  LogService.reconfigure();
  assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation())
      .isFalse();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:CustomConfigWithLogServiceIntegrationTest.java

示例5: setUp

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  Configurator.shutdown();
  BasicAppender.clearInstance();

  this.beforeConfigFileProp =
      System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  this.beforeLevel = StatusLogger.getLogger().getLevel();

  this.customConfigFile = createConfigFileIn(this.temporaryFolder.getRoot());

  System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
      this.customConfigFile.getAbsolutePath());

  Properties gemfireProperties = new Properties();
  gemfireProperties.put(LOCATORS, "");
  gemfireProperties.put(MCAST_PORT, "0");
  gemfireProperties.put(LOG_LEVEL, "info");
  this.cache = new CacheFactory(gemfireProperties).create();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:21,代码来源:CustomConfigWithCacheIntegrationTest.java

示例6: tearDown

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
@After
public void tearDown() throws Exception {
  if (this.cache != null) {
    this.cache.getDistributedSystem().disconnect();
  }

  Configurator.shutdown();

  System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  if (this.beforeConfigFileProp != null) {
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
        this.beforeConfigFileProp);
  }
  StatusLogger.getLogger().setLevel(this.beforeLevel);

  LogService.reconfigure();
  assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation())
      .isTrue();

  BasicAppender.clearInstance();

  assertThat(this.systemErrRule.getLog()).isEmpty();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:CustomConfigWithCacheIntegrationTest.java

示例7: init

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
public void init() {
	try {
		String libraryLocation = ServerWizard2.GIT_LOCATION + File.separator + this.LIBRARY_NAME;
		File chk = new File(libraryLocation);
		if (!chk.exists()) {
			ServerWizard2.LOGGER.info("XML library does not exist so cloning: "+libraryLocation);
			StatusLogger.getLogger().setLevel(Level.FATAL);
			GithubRepository git = new GithubRepository(ServerWizard2.DEFAULT_REMOTE_URL, ServerWizard2.GIT_LOCATION, false);
			git.cloneRepository();
		}
		model.loadLibrary(libraryLocation);
		this.initModel();
	} catch (Exception e) {
		ServerWizard2.LOGGER.severe(e.toString());
		MessageDialog.openError(null, "Error", e.toString());
		e.printStackTrace();
		System.exit(4);
	}
}
 
开发者ID:open-power,项目名称:serverwiz,代码行数:20,代码来源:TargetWizardController.java

示例8: getSupportedCharset

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
/**
 * Returns a Charset, if possible the Charset for the specified {@code charsetName}, otherwise (if the specified
 * {@code charsetName} is {@code null} or not supported) this method returns the platform default Charset.
 *
 * @param charsetName
 *            name of the preferred charset or {@code null}
 * @param defaultCharset
 *            returned if {@code charsetName} is null or is not supported.
 * @return a Charset, never null.
 */
public static Charset getSupportedCharset(final String charsetName, final Charset defaultCharset) {
    Charset charset = null;
    if (charsetName != null) {
        if (Charset.isSupported(charsetName)) {
            charset = Charset.forName(charsetName);
        }
    }
    if (charset == null) {
        charset = defaultCharset;
        if (charsetName != null) {
            StatusLogger.getLogger().error(
                    "Charset " + charsetName + " is not supported for layout, using " + charset.displayName());
        }
    }
    return charset;
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:27,代码来源:Charsets.java

示例9: getReliabilityStrategy

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
/**
 * Returns a new {@code ReliabilityStrategy} instance based on the value of system property
 * {@code log4j.ReliabilityStrategy}. If not value was specified this method returns a new
 * {@code AwaitUnconditionallyReliabilityStrategy}.
 * <p>
 * Valid values for this system property are {@code "AwaitUnconditionally"} (use
 * {@code AwaitUnconditionallyReliabilityStrategy}), {@code "Locking"} (use {@code LockingReliabilityStrategy}) and
 * {@code "AwaitCompletion"} (use the default {@code AwaitCompletionReliabilityStrategy}).
 * <p>
 * Users may also use this system property to specify the fully qualified class name of a class that implements the
 * {@code ReliabilityStrategy} and has a constructor that accepts a single {@code LoggerConfig} argument.
 * 
 * @param loggerConfig the LoggerConfig the resulting {@code ReliabilityStrategy} is associated with
 * @return a ReliabilityStrategy that helps the specified LoggerConfig to log events reliably during or after a
 *         configuration change
 */
public static ReliabilityStrategy getReliabilityStrategy(final LoggerConfig loggerConfig) {

    final String strategy = PropertiesUtil.getProperties().getStringProperty("log4j.ReliabilityStrategy",
            "AwaitCompletion");
    if ("AwaitCompletion".equals(strategy)) {
        return new AwaitCompletionReliabilityStrategy(loggerConfig);
    }
    if ("AwaitUnconditionally".equals(strategy)) {
        return new AwaitUnconditionallyReliabilityStrategy(loggerConfig);
    }
    if ("Locking".equals(strategy)) {
        return new LockingReliabilityStrategy(loggerConfig);
    }
    try {
        final Class<? extends ReliabilityStrategy> cls = LoaderUtil.loadClass(strategy).asSubclass(
            ReliabilityStrategy.class);
        return cls.getConstructor(LoggerConfig.class).newInstance(loggerConfig);
    } catch (final Exception dynamicFailed) {
        StatusLogger.getLogger().warn(
                "Could not create ReliabilityStrategy for '{}', using default AwaitCompletionReliabilityStrategy: {}", strategy, dynamicFailed);
        return new AwaitCompletionReliabilityStrategy(loggerConfig);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:40,代码来源:ReliabilityStrategyFactory.java

示例10: beforeClass

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  final Path src = FileSystems.getDefault().getPath(TARGET_TEST_CLASSES, CONFIG);
  String content = new String(Files.readAllBytes(src), UTF_8);
  final Calendar cal = Calendar.getInstance();
  cal.add(Calendar.SECOND, CRON_DELAY);
  remainingTime = cal.getTimeInMillis() - System.currentTimeMillis();
  cronExpression =  String.format("%d %d %d * * ?",
      cal.get(Calendar.SECOND),
      cal.get(Calendar.MINUTE),
      cal.get(Calendar.HOUR_OF_DAY));
  content = content.replace("@[email protected]", cronExpression);
  Files.write(FileSystems.getDefault()
        .getPath(TARGET_TEST_CLASSES, CONFIG_TARGET), content.getBytes(UTF_8));
  StatusLogger.getLogger().debug("Cron expression will be " + cronExpression + " in " + remainingTime + "ms");
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:RollingAppenderCronOnceADayTest.java

示例11: compress

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
private byte[] compress(final byte[] bytes) {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream(compressionThreshold / 8);
        try (final DeflaterOutputStream stream = compressionType.createDeflaterOutputStream(baos)) {
            if (stream == null) {
                return bytes;
            }
            stream.write(bytes);
            stream.finish();
        }
        return baos.toByteArray();
    } catch (final IOException e) {
        StatusLogger.getLogger().error(e);
        return bytes;
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:GelfLayout.java

示例12: setUp

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的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

示例13: initStartTime

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
/**
 * Returns the result of {@code ManagementFactory.getRuntimeMXBean().getStartTime()},
 * or the current system time if JMX is not available.
 */
private static long initStartTime() {
    // LOG4J2-379:
    // We'd like to call ManagementFactory.getRuntimeMXBean().getStartTime(),
    // but Google App Engine throws a java.lang.NoClassDefFoundError
    // "java.lang.management.ManagementFactory is a restricted class".
    // The reflection is necessary because without it, Google App Engine
    // will refuse to initialize this class.
    try {
        final Class<?> factoryClass = Loader.loadSystemClass("java.lang.management.ManagementFactory");
        final Method getRuntimeMXBean = factoryClass.getMethod("getRuntimeMXBean");
        final Object runtimeMXBean = getRuntimeMXBean.invoke(null);

        final Class<?> runtimeMXBeanClass = Loader.loadSystemClass("java.lang.management.RuntimeMXBean");
        final Method getStartTime = runtimeMXBeanClass.getMethod("getStartTime");
        final Long result = (Long) getStartTime.invoke(runtimeMXBean);

        return result;
    } catch (final Throwable t) {
        StatusLogger.getLogger().error("Unable to call ManagementFactory.getRuntimeMXBean().getStartTime(), "
                + "using system time for OnStartupTriggeringPolicy", t);
        // We have little option but to declare "now" as the beginning of time.
        return System.currentTimeMillis();
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:29,代码来源:OnStartupTriggeringPolicy.java

示例14: setup

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的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

示例15: checkMessageFactory

import org.apache.logging.log4j.status.StatusLogger; //导入依赖的package包/类
/**
 * Checks that the message factory a logger was created with is the same as the given messageFactory. If they are
 * different log a warning to the {@linkplain StatusLogger}. A null MessageFactory translates to the default
 * MessageFactory {@link #DEFAULT_MESSAGE_FACTORY_CLASS}.
 *
 * @param logger The logger to check
 * @param messageFactory The message factory to check.
 */
public static void checkMessageFactory(final ExtendedLogger logger, final MessageFactory messageFactory) {
    final String name = logger.getName();
    final MessageFactory loggerMessageFactory = logger.getMessageFactory();
    if (messageFactory != null && !loggerMessageFactory.equals(messageFactory)) {
        StatusLogger.getLogger().warn(
                "The Logger {} was created with the message factory {} and is now requested with the "
                        + "message factory {}, which may create log events with unexpected formatting.", name,
                loggerMessageFactory, messageFactory);
    } else if (messageFactory == null && !loggerMessageFactory.getClass().equals(DEFAULT_MESSAGE_FACTORY_CLASS)) {
        StatusLogger
                .getLogger()
                .warn("The Logger {} was created with the message factory {} and is now requested with a null "
                        + "message factory (defaults to {}), which may create log events with unexpected "
                        + "formatting.",
                        name, loggerMessageFactory, DEFAULT_MESSAGE_FACTORY_CLASS.getName());
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:26,代码来源:AbstractLogger.java


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