Java 类ch.qos.logback.classic.Level 实例源码

项目:PaymentService    文件:Bitcoin.java   
private Bitcoin() {
    BriefLogFormatter.initWithSilentBitcoinJ();
    ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.toLevel("info"));

    // Context.enableStrictMode();
    final NetworkParameters params = TestNet3Params.get();
    context = new Context(params);
    Context.propagate(context);

    // read system property to check if broken wallet shall be recovered from backup automatically
    automaticallyRecoverBrokenWallet = System.getProperty("automaticallyRecoverBrokenWallet").equalsIgnoreCase("true");

    // prepare (unused) random seed to save time when constructing coupon wallets for invoices
    byte[] seed = new byte[DeterministicSeed.DEFAULT_SEED_ENTROPY_BITS/8];
    List<String> mnemonic = new ArrayList<>(0);
    couponRandomSeed = new DeterministicSeed(seed, mnemonic, MnemonicCode.BIP39_STANDARDISATION_TIME_SECS);
}
项目:jhipster-microservices-example    文件:LogsResource.java   
@PutMapping("/logs")
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerVM jsonLogger) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
项目:JInsight    文件:LogbackInstrumentationTest.java   
@Before
public void setUp() throws Exception {
  registry = RegistryService.getMetricRegistry();

  TagEncodedMetricName rootName = APPENDS_BASE_NAME;
  TagEncodedMetricName throwablesBaseName = THROWABLES_BASE_NAME;

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

  LoggerContext context = new LoggerContext();

  logger = context.getLogger(LogbackInstrumentationTest.class);
  origLevel = logger.getLevel();
  logger.setLevel(Level.ALL);
}
项目:iTAP-controller    文件:DebugEventAppender.java   
/**
 * The logging system calls append for every log message. This method
 * filters out the WARN and ERROR message and adds to a debug event queue
 * that can be accessed via cli or rest-api or gui.
 */
@Override
protected void append(E eventObject) {
    if (!isStarted()) {
        return;
    }
    if (evWarnError != null) {
        ILoggingEvent ev = ((ILoggingEvent) eventObject);
        if (ev.getLevel().equals(Level.ERROR)
            || ev.getLevel().equals(Level.WARN)) {
            evWarnError
            .newEventWithFlush(new WarnErrorEvent(ev.getFormattedMessage(),
                                                  ev.getLevel(),
                                                  ev.getThreadName(),
                                                  ev.getLoggerName()));
        }
    }
}
项目:maxcube-java    文件:Cli.java   
public void run() {
    if (debug) {
        org.slf4j.Logger rootLogger = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
        Logger logbackRootLogger = (Logger) rootLogger;
        logbackRootLogger.setLevel(Level.TRACE);
    }
    try {
        doRun();
    } catch (Exception e) {
        if (debug) {
            LoggerFactory.getLogger(this.getClass()).error("Error while running", e);
        } else {
            System.err.println(String.format(Locale.ROOT, "Error occured: %s", e.getMessage()));
        }
    }

    if (debug) {
        try {
            bos.flush();
            System.err.write(bos.toByteArray());
        } catch (IOException exc) {
            exc.printStackTrace();
        }
    }
}
项目:MTC_Labrat    文件:LogsResource.java   
@PutMapping("/logs")
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerVM jsonLogger) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
项目:tipi-engine    文件:AbstractSpringBootTruncaterTest.java   
protected <T> T doWithLoggingBlocked(String log4jLoggerStr, Log4jBlockingCallback<T> cb) throws Exception {

        ch.qos.logback.classic.Logger logger = null;
        Level loggerLevel = null;
        ch.qos.logback.classic.Logger root = null;
        Level rootLevel = null;
        try {
            logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(log4jLoggerStr);
            loggerLevel = disableLogger(logger);

            final T t = cb.execute();
            return t;
        } finally {
            enableLogger(logger, loggerLevel);
            enableLogger(root, rootLevel);
        }
    }
项目:escalog    文件:LogFmtLayoutTest.java   
@Test
public void fieldsConfigTest()
{
    LogFmtLayout logFmtLayout = new LogFmtLayout();
    logFmtLayout.setFields("time, mdc, custom, level, msg");
    logFmtLayout.setTimeFormat("YYYY");

    Calendar calendar = Calendar.getInstance();
    calendar.set(2017, Calendar.NOVEMBER, 30, 15, 10, 25);

    Map<String, String> mdc = new HashMap<>();
    mdc.put("mdckey", "mdc value");

    ILoggingEvent loggingEvent = createLoggingEvent("thread0", Level.DEBUG, calendar.getTime(),
        with("key1", "value1").and("key2", "val ue2"), "message with \"double quotes\"", mdc);

    assertEquals(
        "time=2017 mdckey=\"mdc value\" key1=value1 key2=\"val ue2\" level=debug msg=\"message with \\\"double quotes\\\"\"\n",
        logFmtLayout.doLayout(loggingEvent)
    );
}
项目:onprom    文件:XESLogExtractorExperimental.java   
public void disableAllOntopLogger(){

    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QuestStatement.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(Quest.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QuestQueryProcessor.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(SparqlAlgebraToDatalogTranslator.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QuestOWL.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QuestUnfolder.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(SQLQueryDeepParser.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(OBDAModelImpl.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(TripleLogger.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(OWLAPITranslatorUtility.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(OWLAPITranslatorOWL2QL.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(MappingVocabularyRepair.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QueryParserRegistry.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(DatalogUnfolder.class)).setLevel(ch.qos.logback.classic.Level.OFF);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(TableNameVisitor.class)).setLevel(ch.qos.logback.classic.Level.OFF);
}
项目:onprom    文件:XESLogExtractor.java   
public void enableAllOntopLogger(){

    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QuestStatement.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(Quest.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QuestQueryProcessor.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(SparqlAlgebraToDatalogTranslator.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QuestOWL.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QuestUnfolder.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(SQLQueryDeepParser.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(OBDAModelImpl.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(TripleLogger.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(OWLAPITranslatorUtility.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(OWLAPITranslatorOWL2QL.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(MappingVocabularyRepair.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(QueryParserRegistry.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(DatalogUnfolder.class)).setLevel(ch.qos.logback.classic.Level.ALL);
    ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(TableNameVisitor.class)).setLevel(ch.qos.logback.classic.Level.ALL);
}
项目:java-coap    文件:ParsingBenchmark.java   
@Before
public void warmUp() throws CoapException {
    ((Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.ERROR);

    packet = new CoapPacket(Method.GET, MessageType.Confirmable, "/path-pppppppppppppppppp1/path-dddddddddd-2/dfdshffsdkjfhsdks3/444444444444444444444444444444444444444/55555555555555555555555555555555555555555555555", null);
    packet.setMessageId(1234);
    packet.setToken(new byte[]{1, 2, 3, 4, 5});
    packet.headers().setMaxAge(4321L);
    packet.headers().setEtag(new byte[]{89, 10, 31, 7, 1});
    packet.headers().setObserve(9876);
    packet.headers().setBlock1Req(new BlockOption(13, BlockSize.S_16, true));
    packet.headers().setContentFormat(MediaTypes.CT_APPLICATION_XML);
    packet.headers().setLocationPath("/1/222/33333/4444444/555555555555555555555555");
    packet.headers().setUriQuery("ppar=val1&par222222222222222222222=val2222222222222222222222222222222222");
    packet.setPayload("<k>12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890</k>");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    packet.writeTo(baos);
    CoapPacket.deserialize(null, new ByteArrayInputStream(baos.toByteArray()));

    System.out.println("MSG SIZE: " + packet.toByteArray().length);
}
项目:app-ms    文件:LogConfigurator.java   
@Override
public void configure(final LoggerContext lc) {

    final ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
    ca.setContext(lc);
    ca.setName("console");
    final LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
    encoder.setContext(lc);
    final TTLLLayout layout = new TTLLLayout();
    layout.setContext(lc);
    layout.start();
    encoder.setLayout(layout);
    ca.setEncoder(encoder);
    ca.start();
    final Logger rootLogger = lc.getLogger("ROOT");
    rootLogger.setLevel(Level.WARN);
    rootLogger.addAppender(ca);
}
项目:verify-hub    文件:UnknownMethodAlgorithmLoggerTest.java   
@Before
public void setUp() throws Exception {
    final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    logger.addAppender(mockAppender);
    logger.setLevel(Level.INFO);

    signature = Optional.of(SignatureBuilder.aSignature().build());
    SignatureImpl signatureImpl = ((SignatureImpl) signature.get());
    signatureImpl.setXMLSignature(BuilderHelper.createXMLSignature(SIGNATURE_RSASHA256, DIGEST_SHA256));

    signatureWithUnknownSignatureAlgorithm = Optional.of(SignatureBuilder.aSignature().withSignatureAlgorithm(SIGNATURE_RSASHA1).build());
    SignatureImpl signatureWithUnknownSignatureAlgorithmImpl = ((SignatureImpl) signatureWithUnknownSignatureAlgorithm.get());
    signatureWithUnknownSignatureAlgorithmImpl.setXMLSignature(BuilderHelper.createXMLSignature(SIGNATURE_RSASHA1, DIGEST_SHA256));

    signatureWithUnknownDigestAlgorithm = Optional.of(SignatureBuilder.aSignature().withDigestAlgorithm(ID, DIGEST_SHA1).build());
    SignatureImpl signatureWithUnknownDigestAlgorithmImpl = ((SignatureImpl) signatureWithUnknownDigestAlgorithm.get());
    signatureWithUnknownDigestAlgorithmImpl.setXMLSignature(BuilderHelper.createXMLSignature(SIGNATURE_RSASHA256, DIGEST_SHA1));

    signatureWithUnknownSignatureAndDigestAlgorithms = Optional.of(SignatureBuilder.aSignature().withSignatureAlgorithm(SIGNATURE_RSASHA1).withDigestAlgorithm(ID, DIGEST_SHA1).build());
    SignatureImpl signatureWithUnknownSignatureAndDigestAlgorithmsImpl = ((SignatureImpl) signatureWithUnknownSignatureAndDigestAlgorithms.get());
    signatureWithUnknownSignatureAndDigestAlgorithmsImpl.setXMLSignature(BuilderHelper.createXMLSignature(SIGNATURE_RSASHA1, DIGEST_SHA1));
}
项目:lambda-monitoring    文件:DefaultMetricsLogbackConfigurator.java   
@Override
public void configure(LoggerContext loggerContext) {
    addInfo("Setting up default configuration.");

    NonMetricsConsoleAppender nonMetricsConsoleAppender = new NonMetricsConsoleAppender();
    nonMetricsConsoleAppender.setContext(loggerContext);
    nonMetricsConsoleAppender.setName("CONSOLE");
    nonMetricsConsoleAppender.start();

    MetricsConsoleAppender metricsConsoleAppender = new MetricsConsoleAppender();
    metricsConsoleAppender.setContext(loggerContext);
    metricsConsoleAppender.setName("METRICS");
    metricsConsoleAppender.start();

    Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.INFO);
    rootLogger.addAppender(nonMetricsConsoleAppender);
    rootLogger.addAppender(metricsConsoleAppender);
}
项目:TOSCAna    文件:LogImplTest.java   
@Test
public void readLogEntriesFromDiskSetLevelCorrectly() {
    log = new LogImpl(logfile);
    Logger testLogger = log.getLogger("my-test-context");
    String[] messages = {"info message", "warn message", "error message"};
    testLogger.info(messages[0]);
    testLogger.warn(messages[1]);
    testLogger.error(messages[2]);
    Log readFromDiskLog = new LogImpl(logfile);
    List<LogEntry> logEntries = readFromDiskLog.getLogEntries(0);
    assertEquals(3, logEntries.size());
    assertTrue(logEntries.get(0).getMessage().contains(messages[0]));
    assertEquals(Level.INFO.toString(), logEntries.get(0).getLevel());
    assertTrue(logEntries.get(1).getMessage().contains(messages[1]));
    assertEquals(Level.WARN.toString(), logEntries.get(1).getLevel());
    assertTrue(logEntries.get(2).getMessage().contains(messages[2]));
    assertEquals(Level.ERROR.toString(), logEntries.get(2).getLevel());
}
项目:TOSCAna    文件:LogImplTest.java   
@Test
public void logReadsLogfileWithStacktraces() {
    log = new LogImpl(logfile);
    Logger testLogger = log.getLogger(getClass());
    try {
        throw new ArithmeticException();
    } catch (ArithmeticException e) {
        testLogger.error("printing stacktrace to log", e);
    }
    Log readFromDiskLog = new LogImpl(logfile);
    List<LogEntry> logEntries = readFromDiskLog.getLogEntries(0);
    for (int index = 0; index < logEntries.size(); index++) {
        LogEntry entry = logEntries.get(index);
        assertNotEquals(0, entry.getTimestamp());
        assertEquals(index, entry.getIndex());
        assertEquals(Level.ERROR.toString(), entry.getLevel());
    }
}
项目:escalog    文件:LogFmtLayoutTest.java   
@Test
public void logFmtLayoutTest()
{

    String appName = "escalog";
    String prefix = "prefix=\"prefix\"";

    LogFmtLayout logFmtLayout = new LogFmtLayout();

    logFmtLayout.setAppName(appName);
    logFmtLayout.setPrefix(prefix);

    Calendar calendar = Calendar.getInstance();
    calendar.set(2017, Calendar.NOVEMBER, 30, 15, 10, 25);
    ILoggingEvent loggingEvent = createLoggingEvent("thread0", Level.DEBUG, calendar.getTime(),
        with("key1", "value1").and("key2", "val ue2"), "message with \"double quotes\"", null);


    assertEquals(
        "prefix=\"prefix\" app=escalog time=\"2017-11-30T15:10:25\" level=debug thread=thread0 msg=\"message with \\\"double quotes\\\"\" key1=value1 key2=\"val ue2\"\n",
        logFmtLayout.doLayout(loggingEvent)
    );

}
项目:java-coap    文件:ServerNotifBenchmark.java   
@Before
public void warmUp() throws CoapException, IOException {
    ((Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.ERROR);

    CoapPacket coapReq = new CoapPacket(Code.C205_CONTENT, MessageType.Confirmable, null);
    coapReq.setMessageId(1234);
    coapReq.setToken(new byte[]{1, 2, 3, 4, 5});
    coapReq.headers().setMaxAge(4321L);
    coapReq.headers().setObserve(6328);
    reqData = coapReq.toByteArray();

    buffer = ByteBuffer.wrap(reqData);
    buffer.position(coapReq.toByteArray().length);

    executor = Executors.newScheduledThreadPool(1);
    trans = new ServerBenchmarkBase.FloodTransportStub(MAX, executor);
    server = CoapServerBuilder.newBuilder().transport(trans).duplicateMsgCacheSize(10000).build();
    server.start();
    server.setObservationHandler(new ObservationHandlerNull());
    System.out.println("MSG SIZE: " + reqData.length);
    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
    //Thread.sleep(4000);
}
项目:micrometer    文件:LogbackMetrics.java   
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
    // cannot use logger.isEnabledFor(level), as it would cause a StackOverflowError by calling this filter again!
    if(level.isGreaterOrEqual(logger.getEffectiveLevel()) && format != null) {
        switch (level.toInt()) {
            case Level.ERROR_INT:
                errorCounter.increment();
                break;
            case Level.WARN_INT:
                warnCounter.increment();
                break;
            case Level.INFO_INT:
                infoCounter.increment();
                break;
            case Level.DEBUG_INT:
                debugCounter.increment();
                break;
            case Level.TRACE_INT:
                traceCounter.increment();
                break;
        }
    }

    return FilterReply.NEUTRAL;
}
项目:logcapture    文件:VerificationExceptionShould.java   
@Test
public void containLogsEventsNotMatchingExpectedWithMdcKeys() {
  Map<String, String> mdcKeys = new HashMap<String, String>() {{
    put("aKey", "aValue");
    put("anotherKey", "anotherValue");
  }};

  ExpectedLoggingMessage expectedLogMessage = aLog().info()
    .withMessage("a log message")
    .withMdc("aKey", equalTo("aValue"))
    .withMdc("anotherKey", equalTo("anotherValue"));

  List<ILoggingEvent> logEvents = Arrays.asList(
    aLoggingEventWith(Level.INFO, "a different message", mdcKeys),
    aLoggingEventWith(Level.INFO, "another different message", mdcKeys)
  );

  VerificationException verificationException = VerificationException.forUnmatchedLog(expectedLogMessage, logEvents);

  assertThat(verificationException.toString()).isEqualTo("com.logcapture.assertion.VerificationException: Expected at least one log matching: \n" +
    "ExpectedLoggingMessage{logLevelMatcher=<INFO>, expectedMessageMatcher=[\"a log message\"], expectedMdc={anotherKey=\"anotherValue\", aKey=\"aValue\"}}\n" +
    "Logs received: \n" +
    "level: INFO marker: null mdc: {anotherKey=anotherValue, aKey=aValue} message: a different message\n" +
    "level: INFO marker: null mdc: {anotherKey=anotherValue, aKey=aValue} message: another different message");
}
项目:simulacron    文件:CommandLineArguments.java   
@Override
public Level convert(String value) {
  Level convertedValue = Level.valueOf(value);

  if (convertedValue == null) {
    throw new ParameterException("Value " + value + "can not be converted to a logging level.");
  }
  return convertedValue;
}
项目:syslogappender    文件:SyslogAppender.java   
public int getSeverityForEvent(Object eventObject) {
  if (eventObject instanceof ILoggingEvent) {
    ILoggingEvent event = (ILoggingEvent) eventObject;
    return LevelToSyslogSeverity.convert(event);
  } else {
    return Level.INFO_INT;
  }
}
项目:escalog    文件:LogFmtLayout.java   
private static String formatLogLevel(Level level)
{
    if ( level == Level.WARN )
    {
        return "warning";
    }

    return level.toString().toLowerCase();
}
项目:micrometer    文件:LogbackMetricsTest.java   
@Test
void logbackLevelMetrics() {
    assertThat(registry.mustFind("logback.events").counter().count()).isEqualTo(0.0);

    logger.setLevel(Level.INFO);

    logger.warn("warn");
    logger.error("error");
    logger.debug("debug"); // shouldn't record a metric

    assertThat(registry.mustFind("logback.events").tags("level", "warn").counter().count()).isEqualTo(1.0);
    assertThat(registry.mustFind("logback.events").tags("level", "debug").counter().count()).isEqualTo(0.0);
}
项目:wngn-jms-kafka    文件:LayoutKafkaMessageEncoderTest.java   
@Test
public void testDoEncode() {
    final LoggerContext ctx = new LoggerContext();
    layout.setContext(ctx);
    layout.setPattern("prefix %msg");
    layout.start();
    final Logger logger = ctx.getLogger("logger");
    final LoggingEvent evt = new LoggingEvent("fqcn", logger, Level.ALL,"message", null, new Object[0]);
    assertThat(unit.doEncode(evt), equalTo("prefix message".getBytes()));
}
项目:butterfly    文件:LogbackLogConfigurator.java   
@Override
public void setLoggerLevel(String logger, org.slf4j.event.Level level) {
    if(level == null) {
        throw new IllegalArgumentException("level argument cannot be null");
    }
    loggerContext.getLogger(logger).setLevel(getLogbackLogLevel(level));
}
项目:logback-nifi-appender    文件:TestNifiAppender.java   
@Test
public void testAppendOneEvent() {
    nifiAppender.start();
    final LoggingEvent evt = new LoggingEvent("fqcn", loggerContext.getLogger("logger"), Level.ALL,
            "Test MessageToNifi", null, new Object[0]);
    nifiAppender.append(evt);
}
项目:ja-micro    文件:CustomLogLevelJsonProvider.java   
@Override
public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException {
    String level;
    switch (event.getLevel().toInt()) {
        case Level.ERROR_INT:
            level = "error";
            break;
        case Level.WARN_INT:
            level = "warning";
            break;
        case Level.INFO_INT:
            level = "info";
            break;
        case Level.DEBUG_INT:
            level = "debug";
            break;
        case Level.TRACE_INT:
            level = "trace";
            break;
        case Level.ALL_INT:
            level = "all";
            break;
        case Level.OFF_INT:
            level = "off";
            break;
        default:
            level = "???";
    }
    JsonWritingUtils.writeStringField(
            generator, getFieldName(), level);
}
项目:fresco_floodlight    文件:DebugEventAppender.java   
public WarnErrorEvent(String message, Level level,
                      String threadName, String logger) {
    this.message = message;
    this.level = level;
    this.threadName = threadName;
    this.logger = logger;
}
项目:sentry    文件:BotCheck.java   
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    if (clientRegistry.getClients().isEmpty()) {
        log.warn("No bots to track data for");
    }
    for (Map.Entry<Bot, IDiscordClient> entry : clientRegistry.getClients().entrySet()) {
        IDiscordClient client = entry.getValue();
        if (client.isReady()) {
            String botTag = "bot:" + entry.getKey().getName();
            for (IShard shard : client.getShards()) {
                String shardTag = "shard:" + shard.getInfo()[0];
                long millis = shard.getResponseTime();
                metricRegistry.timer("discord.ws.response[" + botTag + "," + shardTag + "]")
                    .update(millis, TimeUnit.MILLISECONDS);
            }
            for (IGuild guild : client.getGuilds()) {
                String guildTag = "guild:" + guild.getStringID();
                long online = guild.getUsers().stream()
                    .filter(user -> user.getPresence().getStatus() == StatusType.ONLINE)
                    .count();
                long connected = guild.getUsers().stream()
                    .filter(user -> user.getPresence().getStatus() != StatusType.OFFLINE)
                    .count();
                long joined = guild.getUsers().size();
                String onlineMetric = "discord.ws.users[" + botTag + "," + guildTag + "," + "status:online]";
                String connectedMetric = "discord.ws.users[" + botTag + "," + guildTag + "," + "status:connected]";
                String joinedMetric = "discord.ws.users[" + botTag + "," + guildTag + "," + "status:joined]";
                metricRegistry.histogram(onlineMetric).update(online);
                metricRegistry.histogram(connectedMetric).update(connected);
                metricRegistry.histogram(joinedMetric).update(joined);
            }

         LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
         loggerContext.getLogger("org.eclipse.jetty.websocket").setLevel(Level.WARN);
         loggerContext.getLogger(Discord4J.class).setLevel(Level.DEBUG);
        } else {
            log.warn("Bot {} is not ready!", entry.getKey().getName());
        }
    }
}
项目:thirdcoast    文件:LoggingConfigurator.java   
@Override
public void configure(LoggerContext lc) {
  addInfo("Setting up robot logging configuration.");

  FileAppender<ILoggingEvent> fa = new FileAppender<>();
  fa.setFile("tct.log");
  fa.setAppend(true);
  ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
  ca.setContext(lc);
  ca.setName("console");
  fa.setContext(lc);
  fa.setName("logfile");
  LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
  encoder.setContext(lc);

  PatternLayout layout = new PatternLayout();
  layout.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");

  layout.setContext(lc);
  layout.start();
  encoder.setLayout(layout);

  ca.setEncoder(encoder);
  //    ca.start();
  fa.setEncoder(encoder);
  fa.start();

  Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
  //    rootLogger.addAppender(ca);
  rootLogger.addAppender(fa);
  rootLogger.setLevel(Level.WARN);
}
项目:tipi-engine    文件:AbstractSpringBootTruncaterTest.java   
private Level disableLogger(ch.qos.logback.classic.Logger logger) {
    if (logger != null) {
        Level level = null;
        level = logger.getLevel();
        logger.setLevel(Level.OFF);
        return level;
    }
    return null;
}
项目:java-ilp-plugin    文件:MockQueuedLedgerPluginTest.java   
@BeforeMethod
public void setup() {
  MockitoAnnotations.initMocks(this);

  // Enable debug mode...
  ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME))
      .setLevel(Level.DEBUG);

  this.ledgerInfo = ImmutableLedgerInfo.builder()
      .currencyScale(8)
      .currencyUnit(Monetary.getCurrency("USD"))
      .ledgerPrefix(LEDGER_PREFIX)
      .build();
  final SimulatedLedger simulatedLedger = new SimulatedLedger(ledgerInfo);

  // Initialize the ledger plugin under test...
  this.eventBus = new EventBus();
  this.mockLedgerPlugin = new QueuedMockLedgerPlugin(getLedgerPluginConfig(), simulatedLedger,
      eventBus);

  // Wire-up an async event handler...
  final EventBusLedgerPluginEventHandler asyncLedgerPluginEventHandler
      = new EventBusLedgerPluginEventHandler(ledgerPluginEventHandlerMock);
  eventBus.register(asyncLedgerPluginEventHandler);
  mockLedgerPlugin.addLedgerPluginEventHandler(asyncLedgerPluginEventHandler);
  mockLedgerPlugin.connect();

  // Reset the event handler so we don't count the "connect" event, in general
  reset(ledgerPluginEventHandlerMock);
}
项目:devoxxus-jhipster-microservices-demo    文件:LogsResource.java   
@PutMapping("/logs")
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerVM jsonLogger) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
项目:wngn-jms-kafka    文件:KafkaAppenderTest.java   
@Test
public void testDeferredAppend() {
    when(encoder.doEncode(any(ILoggingEvent.class))).thenReturn(new byte[]{0x00, 0x00});
    unit.start();
    final LoggingEvent deferredEvent = new LoggingEvent("fqcn",ctx.getLogger("org.apache.kafka.clients.logger"), Level.ALL, "deferred message", null, new Object[0]);
    unit.doAppend(deferredEvent);
    verify(deliveryStrategy, times(0)).send(any(KafkaProducer.class), any(ProducerRecord.class), eq(deferredEvent), any(FailedDeliveryCallback.class));
    final LoggingEvent evt = new LoggingEvent("fqcn",ctx.getLogger("logger"), Level.ALL, "message", null, new Object[0]);
    unit.doAppend(evt);
    verify(deliveryStrategy).send(any(KafkaProducer.class), any(ProducerRecord.class), eq(deferredEvent), any(FailedDeliveryCallback.class));
    verify(deliveryStrategy).send(any(KafkaProducer.class), any(ProducerRecord.class), eq(evt), any(FailedDeliveryCallback.class));
}
项目:buenojo    文件:LogsResource.java   
@RequestMapping(value = "/logs",
    method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerDTO jsonLogger) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
项目:wngn-jms-kafka    文件:HostNameKeyingStrategyTest.java   
@Test
public void shouldPartitionByHostName() {
    ctx.putProperty(CoreConstants.HOSTNAME_KEY, "localhost");
    unit.setContext(ctx);
    final ILoggingEvent evt = new LoggingEvent("fqcn", ctx.getLogger("logger"), Level.ALL, "msg", null, new Object[0]);
    Assert.assertThat(unit.createKey(evt), Matchers.equalTo(ByteBuffer.allocate(4).putInt("localhost".hashCode()).array()));
}
项目:spring-io    文件:LogsResource.java   
@PutMapping("/logs")
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerVM jsonLogger) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
项目:EatDubbo    文件:LogbackContainer.java   
/**
 * Initializer logback
 * 
 * @param file
 * @param level
 * @param maxHistory
 */
private void doInitializer(String file, String level, int maxHistory) {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.detachAndStopAllAppenders();

    // appender
    RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
    fileAppender.setContext(loggerContext);
    fileAppender.setName("application");
    fileAppender.setFile(file);
    fileAppender.setAppend(true);

    // policy
    TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<ILoggingEvent>();
    policy.setContext(loggerContext);
    policy.setMaxHistory(maxHistory);
    policy.setFileNamePattern(file + ".%d{yyyy-MM-dd}");
    policy.setParent(fileAppender);
    policy.start();
    fileAppender.setRollingPolicy(policy);

    // encoder
    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(loggerContext);
    encoder.setPattern("%date [%thread] %-5level %logger (%file:%line\\) - %msg%n");
    encoder.start();
    fileAppender.setEncoder(encoder);

    fileAppender.start();

    rootLogger.addAppender(fileAppender);
    rootLogger.setLevel(Level.toLevel(level));
    rootLogger.setAdditive(false);
}
项目:verify-hub    文件:NotOnOrAfterLoggerTest.java   
private static void verifyLog(
        final Appender mockAppender,
        final ArgumentCaptor<LoggingEvent> captorLoggingEvent,
        final String expectedMessage) {
    verify(mockAppender, times(1)).doAppend(captorLoggingEvent.capture());
    final LoggingEvent loggingEvent = captorLoggingEvent.getValue();
    assertThat(loggingEvent.getLevel(), is(Level.INFO));

    assertThat(loggingEvent.getFormattedMessage(), is(expectedMessage));
}