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


Java LogManager类代码示例

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


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

示例1: test

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
@Test
public void test() {
    {
        Logger logger = LogManager.getLogger("test.logger");
        logger.error("This is an error!");
        logger.error("This is another error!");
        logger.error("This is a third error!");
    }

    assertThat(collector.getLogs()).hasSize(3)
            .contains("This is an error!", "This is another error!", "This is a third error!");

    List<LogEvent> rawLogs = (List<LogEvent>) collector.getRawLogs();
    assertThat(rawLogs).hasSize(3);

    assertTrue(rawLogs.stream().allMatch(l -> l.getLevel() == Level.ERROR));
}
 
开发者ID:haasted,项目名称:TestLogCollectors,代码行数:18,代码来源:Log4j2Test.java

示例2: toggleCleanLogging

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
private void toggleCleanLogging() {
	
	this.cleanLogging = !cleanLogging;
	interactionHandler.sendText("clean logging: " + cleanLogging);
	String appenderToAdd = cleanLogging ? "Clean" : "Console";
	String appenderToRemove = cleanLogging ? "Console" : "Clean";
	
       final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
       final Configuration config = ctx.getConfiguration();
       
       for (org.apache.logging.log4j.core.Logger logger : ctx.getLoggers()) {
       	
       	logger.removeAppender(config.getAppender(appenderToRemove));
       	config.addLoggerAppender(logger, config.getAppender(appenderToAdd));
       }
       ctx.updateLoggers();
	
}
 
开发者ID:OpenBW,项目名称:TSBW4J,代码行数:19,代码来源:Bot.java

示例3: init

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
@Override
public boolean init(String botId, Map<String, String> configs, String[] channels) {
    logger = LogManager.getLogger(TelegramBot.class.getSimpleName() + ":" + botId);

    this.configs = configs;

    try {
        telegramBotsApi.registerBot(this);
    } catch (TelegramApiRequestException e) {
        logger.error(e);
        return false;
    }

    this.botId = botId;

    return true;
}
 
开发者ID:KDE,项目名称:brooklyn,代码行数:18,代码来源:TelegramBot.java

示例4: DebeziumPipeLine

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
public DebeziumPipeLine(Context cxt, SourceConfig conf, String topic) throws BiremeException {
  super(cxt, conf, "Debezium-" + conf.name + "-" + topic);

  this.conf = conf;

  List<TopicPartition> topicPartition =
      consumer.partitionsFor(topic)
          .stream()
          .map(p -> new TopicPartition(p.topic(), p.partition()))
          .collect(Collectors.toList());
  consumer.subscribe(Arrays.asList(topic));

  logger = LogManager.getLogger("Bireme." + myName);
  logger.info("Create new Debezium PipeLine. Name: {}", myName);

  if (topicPartition.size() > 1) {
    logger.error("Topic {} has {} partitions", topic, topicPartition.size());
    String message = "Topic has more than one partitions";
    throw new BiremeException(message);
  }
}
 
开发者ID:HashDataInc,项目名称:bireme,代码行数:22,代码来源:DebeziumPipeLine.java

示例5: mapChartData

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
public List<PoloniexChartData> mapChartData(String chartDataResult) {

        if (INVALID_CHART_DATA_DATE_RANGE_RESULT.equals(chartDataResult) || INVALID_CHART_DATA_CURRENCY_PAIR_RESULT.equals(chartDataResult)) {
            return Collections.EMPTY_LIST;
        }

        List<PoloniexChartData> results;
        try {
            PoloniexChartData[] chartDataResults = gson.fromJson(chartDataResult, PoloniexChartData[].class);
            results = Arrays.asList(chartDataResults);
        } catch (JsonSyntaxException | DateTimeParseException ex) {
            LogManager.getLogger().error("Exception mapping chart data {} - {}", chartDataResult, ex.getMessage());
            results = Collections.EMPTY_LIST;
        }
        return results;

    }
 
开发者ID:TheCookieLab,项目名称:poloniex-api-java,代码行数:18,代码来源:PoloniexDataMapper.java

示例6: main

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
public static void main(String[] args) {
	final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
	final Configuration config = ctx.getConfiguration();
	config.getLoggerConfig(strategy.Portfolio.class.getName()).setLevel(Level.WARN);
	ctx.updateLoggers(config);
	
	final CommonParam cp = ParamManager.getCommonParam("m", TIME_FRAME.MIN60, "19980101 000000", "20160101 170000");
	
	StrategyOptimizer so = new StrategyOptimizer(tester.RealStrategyTester.class);
	so.setInstrumentParam(cp.instrument, cp.tf);
	so.setTestDateRange((int) DateTimeHelper.Ldt2Long(cp.start_date), (int) DateTimeHelper.Ldt2Long(cp.end_date));
	int num = so.setStrategyParamRange(DblMaPsarStrategy.class, new Integer[]{3, 5, 1}, new Integer[]{10, 100, 2}, MA.MA_MODES, new APPLIED_PRICE[] {APPLIED_PRICE.PRICE_CLOSE, APPLIED_PRICE.PRICE_TYPICAL}, new Float[]{0.01f, 0.02f, 0.01f}, new Float[]{0.12f, 0.2f, 0.02f});
	System.out.println(num);
	so.StartOptimization();
	Set<Entry<Object[],Performances>> entryset = so.result_db.entrySet();
	for (Entry<Object[],Performances> entry : entryset) {
		for (Object obj : entry.getKey()) {
			System.out.print(obj + ",\t");
		}
		System.out.println("ProfitRatio: " + String.format("%.5f", entry.getValue().ProfitRatio) + "\tMaxDrawDown: " + entry.getValue().MaxDrawDown);
	}
}
 
开发者ID:zc8424,项目名称:QuantTester,代码行数:23,代码来源:OptimizeDblMaPsar.java

示例7: toggleAutoRenew

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
@Override
public PoloniexLendingResult toggleAutoRenew(String orderNumber)
{
    long start = System.currentTimeMillis();
    PoloniexLendingResult result = null;
    try
    {
        String res = tradingClient.toggleAutoRenew(orderNumber);
        result = mapper.mapLendingResult(res);
        LogManager.getLogger(PoloniexLendingService.class).trace("Executed and mapped toggleAutoRenew for {} in {} ms", orderNumber, System.currentTimeMillis() - start);
    }
    catch (Exception ex)
    {
        LogManager.getLogger(PoloniexLendingService.class).error("Error executing toggleAutoRenew for {} - {}", orderNumber, ex.getMessage());
    }

    return result;
}
 
开发者ID:TheCookieLab,项目名称:poloniex-api-java,代码行数:19,代码来源:PoloniexLendingService.java

示例8: init

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
@Override
public boolean init(String botId, Map<String, String> configs, String[] channels) {
    logger = LogManager.getLogger(IrcBot.class.getSimpleName() + ":" + botId);

    if (!configs.containsKey(USERNAME_KEY))
        return false;
    if (!configs.containsKey(HOST_KEY))
        return false;

    client = Client.builder()
            .nick(configs.get(USERNAME_KEY))
            .serverHost(configs.get(HOST_KEY))
            .listenInput(line -> logger.debug("[I]: " + line))
            .listenOutput(line -> logger.debug("[O]: " + line))
            .listenException(logger::error)
            .defaultMessageMap(new SimpleDefaultMessageMap())
            .build();

    client.getEventManager().registerEventListener(this);
    this.botId = botId;
    this.configs = configs;
    this.channels = channels;

    return true;
}
 
开发者ID:KDE,项目名称:brooklyn,代码行数:26,代码来源:IrcBot.java

示例9: func_181670_b

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
private void func_181670_b(int p_181670_1_)
{
    if (p_181670_1_ > this.rawIntBuffer.remaining())
    {
        int i = this.byteBuffer.capacity();
        int j = i % 2097152;
        int k = j + (((this.rawIntBuffer.position() + p_181670_1_) * 4 - j) / 2097152 + 1) * 2097152;
        LogManager.getLogger().warn("Needed to grow BufferBuilder buffer: Old size " + i + " bytes, new size " + k + " bytes.");
        int l = this.rawIntBuffer.position();
        ByteBuffer bytebuffer = GLAllocation.createDirectByteBuffer(k);
        this.byteBuffer.position(0);
        bytebuffer.put(this.byteBuffer);
        bytebuffer.rewind();
        this.byteBuffer = bytebuffer;
        this.rawFloatBuffer = this.byteBuffer.asFloatBuffer().asReadOnlyBuffer();
        this.rawIntBuffer = this.byteBuffer.asIntBuffer();
        this.rawIntBuffer.position(l);
        this.field_181676_c = this.byteBuffer.asShortBuffer();
        this.field_181676_c.position(l << 1);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:22,代码来源:WorldRenderer.java

示例10: setUp

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  registry = RegistryService.getMetricRegistry();

  meters = new HashMap<>();
  meters.put("total", getMeter(APPENDS_BASE_NAME.submetric("total")));
  meters.put("trace", getMeter(APPENDS_BASE_NAME.withTags("level", "trace")));
  meters.put("debug", getMeter(APPENDS_BASE_NAME.withTags("level", "debug")));
  meters.put("info", getMeter(APPENDS_BASE_NAME.withTags("level", "info")));
  meters.put("warn", getMeter(APPENDS_BASE_NAME.withTags("level", "warn")));
  meters.put("error", getMeter(APPENDS_BASE_NAME.withTags("level", "error")));
  meters.put("fatal", getMeter(APPENDS_BASE_NAME.withTags("level", "fatal")));
  meters.put("throwCount", getMeter(THROWABLES_BASE_NAME.submetric("total")));
  meters.put("throw[RuntimeException]", getMeter(THROWABLES_BASE_NAME
          .withTags("class", RuntimeException.class.getName())
  ));

  logger = LogManager.getLogger(Log4J2InstrumentationTest.class.getName());
  origLevel = logger.getLevel();
  setLogLevel(logger, Level.ALL);

}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:23,代码来源:Log4J2InstrumentationTest.java

示例11: write

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
private void write(String data) {
  try {
    FileUtils.writeStringToFile(logFile, data + Character.LINE_SEPARATOR, "UTF-8", true);
  } catch (IOException e) {
    LogManager.getLogger(getClass()).error("Failed writing to raffle log", e);
  }
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:8,代码来源:RaffleLogFile.java

示例12: main

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
public static void main(String[] args) {
	final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
	final Configuration config = ctx.getConfiguration();
	config.getLoggerConfig(strategy.Portfolio.class.getName()).setLevel(Level.WARN);
	ctx.updateLoggers(config);
	
	final CommonParam cp = ParamManager.getCommonParam("i", TIME_FRAME.MIN15, "20080101 000000", "20160101 170000");
	
	StrategyOptimizer so = new StrategyOptimizer(tester.RealStrategyTester.class);
	so.setInstrumentParam(cp.instrument, cp.tf);
	so.setTestDateRange((int) DateTimeHelper.Ldt2Long(cp.start_date), (int) DateTimeHelper.Ldt2Long(cp.end_date));
	int num = so.setStrategyParamRange(MaPsarStrategy.class, new Integer[]{12, 500, 2}, new String[]{MA.MODE_EMA, MA.MODE_SMMA}, new APPLIED_PRICE[] {APPLIED_PRICE.PRICE_CLOSE, APPLIED_PRICE.PRICE_TYPICAL}, new Float[]{0.01f, 0.02f, 0.01f}, new Float[]{0.1f, 0.2f, 0.02f});
	System.out.println(num);
	so.StartOptimization();
	Set<Entry<Object[],Performances>> entryset = so.result_db.entrySet();
	for (Entry<Object[],Performances> entry : entryset) {
		for (Object obj : entry.getKey()) {
			System.out.print(obj + ",\t");
		}
		System.out.println("ProfitRatio: " + String.format("%.5f", entry.getValue().ProfitRatio) + "\tMaxDrawDown: " + entry.getValue().MaxDrawDown);
	}
}
 
开发者ID:zc8424,项目名称:QuantTester,代码行数:23,代码来源:OptimizeMaPsar.java

示例13: initLog

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
protected static void initLog(){

        if (AschSDK.Config.isDebugMode()) {
            final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
            ctx.getConfiguration()
                    .getRootLogger()
                    .setLevel(Level.ALL);
        }
    }
 
开发者ID:AschPlatform,项目名称:asch-java,代码行数:10,代码来源:Main.java

示例14: getContext

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
/**
 * Gets the {@link LoggerContext} associated with the given caller class.
 *
 * @param callerClass the caller class
 * @return the LoggerContext for the calling class
 */
protected LoggerContext getContext(final Class<?> callerClass) {
    ClassLoader cl = null;
    if (callerClass != null) {
        cl = callerClass.getClassLoader();
    }
    if (cl == null) {
        cl = LoaderUtil.getThreadContextClassLoader();
    }
    return LogManager.getContext(cl, false);
}
 
开发者ID:battlesteed,项目名称:hibernateMaster,代码行数:17,代码来源:Log4jLoggerFactory.java

示例15: onLogLevelChanged

import org.apache.logging.log4j.LogManager; //导入依赖的package包/类
/**
 * When the user changes the log level and new {@link Runnable} command is added to {@link Settings}.
 * <p>
 * Command run when the user applies the change in setting.
 *
 * @param event action event
 */
@FXML
public void onLogLevelChanged(final ActionEvent event) {
    settings.addRunnable(() -> {
        final String logLevel = choiceBox.getSelectionModel().getSelectedItem();

        final Logger logger = LogManager.getRootLogger();
        Configurator.setLevel(logger.getName(), Level.toLevel(logLevel));

        LOGGER.info("Log level was set to: " + Level.toLevel(logLevel));
    });

    event.consume();
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:21,代码来源:LoggingSettingsViewController.java


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