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

项目: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();
        }
    }
}
项目: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);
}
项目:java-coap    文件:ServerBenchmark.java   
@Before
public void warmUp() throws CoapException, IOException {
    ((Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.ERROR);

    CoapPacket coapReq = new CoapPacket(Method.GET, MessageType.Confirmable, "/path1/sub2/sub3", null);
    coapReq.setMessageId(1234);
    coapReq.setToken(new byte[]{1, 2, 3, 4, 5});
    coapReq.headers().setMaxAge(4321L);
    reqData = coapReq.toByteArray();

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

    trans = new SynchTransportStub();
    server = CoapServerBuilder.newBuilder().transport(trans).build();
    server.addRequestHandler("/path1/sub2/sub3", new ReadOnlyCoapResource("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));
    server.start();
    System.out.println("MSG SIZE: " + reqData.length);
}
项目:onprom    文件:XESLogExtractor.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);
}
项目:cdp4j    文件:TestAll.java   
@BeforeClass
@SuppressWarnings("unchecked")
public static void init() {
    loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

    appender = new CdpAppender();
    appender.setContext(loggerContext);
    appender.start();
    appender.setName(CdpAppender.class.getName());

    Logger logger = loggerContext.getLogger("cdp4j.flow");
    logger.addAppender((Appender<ILoggingEvent>) appender);

    factory = new Launcher().launch();

    session = factory.create();

    session.enableConsoleLog();

    URL url = TestAll.class.getResource("/session-test.html");
    session.navigate(url.toString());
}
项目: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));
}
项目: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;
}
项目:java-coap    文件:ServerBenchmarkBase.java   
@Before
public void warmUp() throws CoapException, IOException {
    ((Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.ERROR);

    CoapPacket coapReq = new CoapPacket(Method.GET, MessageType.Confirmable, "/path1/sub2/sub3", null);
    coapReq.setMessageId(1234);
    coapReq.setToken(new byte[]{1, 2, 3, 4, 5});
    coapReq.headers().setMaxAge(4321L);
    reqData = coapReq.toByteArray();

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

    server = CoapServerBuilder.newBuilder().transport(trans).duplicateMsgCacheSize(10000).build();
    server.addRequestHandler("/path1/sub2/sub3", new ReadOnlyCoapResource("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));
    server.start();
    System.out.println("MSG SIZE: " + reqData.length);
    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
    //Thread.sleep(4000);
}
项目:syslogappender    文件:SyslogAppenderTest.java   
@Test
public void testTcpSender() throws JoranException, InterruptedException {
  LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
  JoranConfigurator configurator = new JoranConfigurator();
  configurator.setContext(context);
  context.reset();
  configurator.doConfigure(this.getClass().getClassLoader().getResourceAsStream("logback-syslog-tcp.xml"));

  Logger logger = context.getLogger("test-tcp");
  logger.info("test message over tcp");

  context.stop();
  Thread.sleep(100);

  final String serverData = serverStream.toString();
  assertTrue("Server received: " + serverData, serverData.contains("test message over tcp"));
}
项目:syslogappender    文件:SyslogAppenderTest.java   
@Test
public void testTlsSender() throws JoranException, InterruptedException {
  LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
  JoranConfigurator configurator = new JoranConfigurator();
  configurator.setContext(context);
  context.reset();
  configurator.doConfigure(this.getClass().getClassLoader().getResourceAsStream("logback-syslog-tls.xml"));

  Logger logger = context.getLogger("test-tls");
  logger.info("test message over tls");

  context.stop();
  Thread.sleep(100);

  final String serverData = serverStream.toString();
  assertTrue("Server received: " + serverData, serverData.contains("test message over tls"));
}
项目: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);
}
项目:logcapture    文件:LogCaptureRule.java   
@Override
public Statement apply(Statement base, FrameworkMethod method, Object target) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      logAppender = new StubAppender();
      Logger root = (Logger) LoggerFactory.getLogger(loggerName);

      root.addAppender(logAppender);
      try {
        base.evaluate();
      } finally {
        root.detachAppender(logAppender);
      }
    }
  };
}
项目: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);
}
项目:maxcube-java    文件:Cli.java   
private static void configureInMemoryLogging() {
    org.slf4j.Logger rootLogger = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    Logger logbackRootLogger = (Logger) rootLogger;
    logbackRootLogger.setLevel(Level.INFO);

    OutputStreamAppender<ILoggingEvent> appender = new OutputStreamAppender<>();
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    PatternLayoutEncoder ple = new PatternLayoutEncoder();
    ple.setPattern("[%date] [%level] [%logger{10}] %msg%n");
    ple.setContext(lc);
    ple.start();
    try {
        ple.init(bos);
    } catch (IOException e) {
    }
    appender.setContext(lc);
    appender.setOutputStream(bos);
    appender.setName("buffered");
    appender.setEncoder(ple);
    appender.start();

    logbackRootLogger.detachAppender("console");
    logbackRootLogger.addAppender(appender);
    logbackRootLogger.setAdditive(true);
}
项目:Phial    文件:PhialLogger.java   
/**
 * Create new log entry in file.
 * <p>
 * You should not call it directly from your application build some facade (or use Timber) and set it to write to
 * PhialLogger.
 *
 * @param priority Log level. See {@link Log} for constants.
 * @param tag      Explicit or inferred tag. May be {@code null}.
 * @param message  Formatted log message. May be {@code null}.
 * @param t        Accompanying exceptions. May be {@code null}.
 */
public void log(int priority, String tag, String message, Throwable t) {
    final org.slf4j.Logger logger = LoggerFactory.getLogger(tag);

    switch (priority) {
        case Log.VERBOSE:
            logger.trace(message, t);
            break;
        case Log.DEBUG:
            logger.debug(message, t);
            break;
        case Log.INFO:
            logger.info(message, t);
            break;
        case Log.WARN:
            logger.warn(message, t);
            break;
        case Log.ERROR:
            logger.error(message, t);
            break;
        default:
            logger.error("unexpected Log priority: " + priority + " " + message, t);
            break;
    }
}
项目:secondbase    文件:SecondBaseLoggerTest.java   
@Test
public void shouldSetConsoleAppender() {
    final String nullRequestLoggerName = null;
    SecondBaseLogger.setupLoggingStdoutOnly(KEYS, VALUES, nullRequestLoggerName);
    final ch.qos.logback.classic.Logger rootLogger
            = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(
                    org.slf4j.Logger.ROOT_LOGGER_NAME);
    final Appender<ILoggingEvent> serviceConsoleAppender = rootLogger.getAppender(
            "SERVICECONSOLEAPPENDER");

    assertThat(serviceConsoleAppender, notNullValue());
}
项目:jhipster-microservices-example    文件:LoggerVMTest.java   
@Test
public void getNameTest() throws Exception {
    LoggerVM vm = new LoggerVM();
    assertNull(vm.getName());

    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    vm = new LoggerVM(logger);
    assertEquals(Logger.ROOT_LOGGER_NAME, vm.getName());
}
项目:RefDiff    文件:TestWithCalibrationDataset.java   
public static void main(String[] args) {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
       root.setLevel(Level.INFO);

       RefDiffConfigImpl config = new RefDiffConfigImpl();
       config.setId("xfinal");
       config.setThreshold(RelationshipType.MOVE_TYPE, 0.1);
       config.setThreshold(RelationshipType.RENAME_TYPE, 0.4);
       config.setThreshold(RelationshipType.EXTRACT_SUPERTYPE, 0.3);
       config.setThreshold(RelationshipType.MOVE_METHOD, 0.4);
       config.setThreshold(RelationshipType.RENAME_METHOD, 0.3);
       config.setThreshold(RelationshipType.PULL_UP_METHOD, 0.4);
       config.setThreshold(RelationshipType.PUSH_DOWN_METHOD, 0.6);
       config.setThreshold(RelationshipType.EXTRACT_METHOD, 0.3);
       config.setThreshold(RelationshipType.INLINE_METHOD, 0.3);
       config.setThreshold(RelationshipType.MOVE_FIELD, 0.1);
       config.setThreshold(RelationshipType.PULL_UP_FIELD, 0.2);
       config.setThreshold(RelationshipType.PUSH_DOWN_FIELD, 0.2);

    CalibrationDataset dataset = new CalibrationDataset();
    ResultComparator rc = new ResultComparator();
    rc.expect(dataset.getExpected());
    rc.dontExpect(dataset.getNotExpected());

    RefDiff refdiff = new RefDiff(config);
    for (RefactoringSet commit : dataset.getExpected()) {
        rc.compareWith("refdiff", ResultComparator.collectRmResult(refdiff, commit.getProject(), commit.getRevision()));
    }
    EnumSet<RefactoringType> types = EnumSet.complementOf(EnumSet.of(RefactoringType.MOVE_RENAME_CLASS));
    rc.printSummary(System.out, types);
    rc.printDetails(System.out, types);

    CompareResult r = rc.getCompareResult("refdiff", types);
    printTable3(r);
}
项目:jhipster-microservices-example    文件:LoggerVMTest.java   
@Test
public void toStringTestTest() throws Exception {
    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    LoggerVM vm = new LoggerVM(logger);
    assertTrue(vm.toString().startsWith(LoggerVM.class.getSimpleName()));
    String json = vm.toString().replace(LoggerVM.class.getSimpleName(), "");
    assertTrue(TestUtils.isValid(json));
}
项目:spring-cloud-ribbon-extensions    文件:HttpLoggingConfig.java   
@Bean
@ConditionalOnClass(Logger.class)
public CommonsRequestLoggingFilter springLogging() {
    Logger logger = (Logger) LoggerFactory.getLogger(CommonsRequestLoggingFilter.class);
    logger.setLevel(Level.DEBUG);
    log.info("Http logging enabled {}.", properties);
    return requestLoggingFilter();
}
项目:secondbase    文件:SecondBaseLoggerTest.java   
@Test
public void customFieldsShouldBeLoggedWithPatternLayout() throws IOException {
    final ArgumentCaptor<LoggingEvent> captorLoggingEvent = ArgumentCaptor.forClass(
            LoggingEvent.class);

    final LoggerContext loggerContext = SecondBaseLogger.getLoggerContext(
            new String[] {"environment", "service", "datacenter"},
            new String[] {"environment", "service", "datacenter"}
    );
    final Appender<ILoggingEvent> mockAppender = spy(
            SecondBaseLogger.createPatternLayoutConsoleAppender(
                    SecondBaseLogger.SERVICE_CONSOLE_APPENDER, loggerContext, true));
    final Logger rootLogger = (Logger) LoggerFactory.getLogger(
            org.slf4j.Logger.ROOT_LOGGER_NAME);
    rootLogger.addAppender(mockAppender);
    final org.slf4j.Logger logger = LoggerFactory.getLogger(SecondBaseLoggerTest.class);
    logger.info("log message");

    verify(mockAppender).doAppend(captorLoggingEvent.capture());

    final LoggingEvent loggingEvent = captorLoggingEvent.getValue();
    final LoggingEventCompositeJsonEncoder encoder = SecondBaseLogger.getEncoder(
            loggerContext, true);
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    encoder.start();
    outputStream.write(encoder.encode(loggingEvent));
    final ObjectMapper mapper = new ObjectMapper();
    final JsonNode node = mapper.readTree(outputStream.toByteArray());

    assertThat(node.get("message").asText(), is("log message"));
    assertThat(node.get("environment").asText(), is("environment"));
    assertThat(node.get("datacenter").asText(), is("datacenter"));
    assertThat(node.get("service").asText(), is("service"));
    assertThat(node.get("level").asText(), is("INFO"));
    assertThat(node.has("timestamp"), is(true));
    assertThat(node.get("type").asText(), is("servicelog"));
    encoder.stop();
    outputStream.close();
}
项目:uavstack    文件:LogBackHookProxy.java   
/**
 * figure out the logback's configuration: for example, appenders' file path, buff io, etc...
 * 
 * @param context
 * @param webapploader
 */
private void figureOutLogBackConfig(HookContext context, ClassLoader webapploader) {

    Logger logback = (Logger) LoggerFactory.getLogger(LogBackHookProxy.class);

    InterceptContext interceptContext = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);

    if (interceptContext == null) {
        logback.warn("No InterceptContext available, can't figure out LogBack configuration.");
        return;
    }

    @SuppressWarnings("unchecked")
    LinkedList<LogProfileInfo> list = (LinkedList<LogProfileInfo>) interceptContext
            .get(HookConstants.LOG_PROFILE_LIST);

    if (null == list) {
        list = new LinkedList<LogProfileInfo>();
        interceptContext.put(HookConstants.LOG_PROFILE_LIST, list);
    }

    String appid = (String) (interceptContext.get(InterceptConstants.CONTEXTPATH));

    // figureour all loggers
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

    List<ch.qos.logback.classic.Logger> loggers = loggerContext.getLoggerList();

    for (Logger logger : loggers) {
        figureoutLogConfiguration(logger, list, appid);
    }

}
项目:TOSCAna    文件:LogImpl.java   
@Override
public Logger getLogger(String context) {
    Logger logger = (Logger) LoggerFactory.getLogger(context);
    MemoryAppender memoryAppender = new MemoryAppender(this);
    PersistentAppender persistentAppender = new PersistentAppender(logFile);
    logger.addAppender(memoryAppender);
    logger.addAppender(persistentAppender);
    logger.setLevel(Level.DEBUG);
    logger.setAdditive(true); /* set to true if root should log too */
    return logger;
}
项目:json-log-domain    文件:LogbackJUnitRule.java   
public static LogbackJUnitRule newInstance(Class<?> ... classes) {
    LogbackJUnitRule rule = new LogbackJUnitRule();

    if(classes != null && classes.length > 0) {
        for (Class<?> cls : classes) {
            rule.add(cls);
        }
    } else {
        rule.add(Logger.ROOT_LOGGER_NAME);
    }

    return rule;
}
项目:dubbox-hystrix    文件: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);
}
项目:json-log-domain    文件:LogbackJUnitRule.java   
public List<ILoggingEvent> capture(String name) {
    Logger logger = (Logger) LoggerFactory.getLogger(name);

    for(Entry entry : entries) {
        if(entry.logger == logger) {
            return entry.appender.list;
        }
    }

    throw new IllegalArgumentException("Unable to find logger for " + name);
}
项目:NoraUi    文件:OutputConsoleDataProviderUT.java   
@Test
public void testWriteXxxxxResult() throws TechnicalException {
    final OutputConsoleDataProvider outputConsoleDataProvider = new OutputConsoleDataProvider();
    outputConsoleDataProvider.prepare("hello");
    Assert.assertTrue(true);

    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);

    final TestAppender<ILoggingEvent> appender = new TestAppender<>();
    appender.start();
    logger.addAppender(appender);
    outputConsoleDataProvider.writeFailedResult(1, "UT Failed Message");
    List<ILoggingEvent> log = appender.getLog();
    Assert.assertEquals(Level.ERROR, log.get(0).getLevel());
    Assert.assertTrue(log.get(0).getMessage().toString().endsWith(String.format(Messages.getMessage("OUTPUT_CONSOLE_DATA_PROVIDER_FAILED_AT_LINE"), 1, "UT Failed Message")));

    outputConsoleDataProvider.writeSuccessResult(2);
    log = appender.getLog();
    Assert.assertEquals(Level.INFO, log.get(1).getLevel());
    Assert.assertTrue(log.get(1).getMessage().toString().endsWith(String.format(Messages.getMessage("OUTPUT_CONSOLE_DATA_PROVIDER_SUCCESS_AT_LINE"), 2)));

    outputConsoleDataProvider.writeWarningResult(3, "UT Warning Message");
    log = appender.getLog();
    Assert.assertEquals(Level.WARN, log.get(2).getLevel());
    Assert.assertTrue(log.get(2).getMessage().toString().endsWith(String.format(Messages.getMessage("OUTPUT_CONSOLE_DATA_PROVIDER_WARNING_AT_LINE"), 3, "UT Warning Message")));

    outputConsoleDataProvider.writeDataResult("title", 4, "UT title");
    log = appender.getLog();
    Assert.assertEquals(Level.INFO, log.get(3).getLevel());
    Assert.assertTrue(log.get(3).getMessage().toString().endsWith(String.format(Messages.getMessage("OUTPUT_CONSOLE_DATA_PROVIDER_RESULT_AT_LINE"), 4, "title", "UT title")));
}
项目:dubbo2    文件: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);
}
项目:secondbase    文件:SecondBaseLoggerTest.java   
@Test
public void shouldSetConsoleAndServiceLayoutAppenders() {
    final boolean json = false;
    SecondBaseLogger.setupLoggingStdoutOnly(KEYS, VALUES, null, json);
    final ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory
            .getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    final Appender<ILoggingEvent> consoleAppender = rootLogger
            .getAppender("SERVICECONSOLEAPPENDER");

    assertThat(consoleAppender, notNullValue());
}
项目:heat    文件:LoggingUtils.java   
private void log(String mode, String message, Object... params) {
    try {
        org.slf4j.Logger logger = LoggerFactory.getLogger(getCurrentClass(THREAD_COUNT_LOG_LEVEL));
        Class[] cArg = new Class[2];
        cArg[0] = String.class;
        cArg[1] = Object[].class;
        Method loggerMethod = logger.getClass().getMethod(mode, cArg);
        loggerMethod.invoke(logger, getTestCaseLogDetails() + " -- " + message, params);
    } catch (Exception oEx) {
        throw new HeatException(getExceptionDetails() + oEx.getClass()
                + " / cause: '" + oEx.getCause() + "' / message: '" + oEx.getLocalizedMessage() + "'");
    }
}
项目:karate    文件:ReporterLogAppender.java   
public ReporterLogAppender() {
    sb = new StringBuilder();
    this.threadName = Thread.currentThread().getName();
    this.logger = (Logger) LoggerFactory.getLogger("com.intuit.karate");
    setName("karate-reporter");
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    setContext(lc);        
    encoder = new PatternLayoutEncoder();
    encoder.setPattern("%d{HH:mm:ss.SSS} %-5level - %msg%n");
    encoder.setContext(context);
    encoder.start();
    start();
    logger.addAppender(this);     
}
项目:dremio-oss    文件:YarnTwillLogHandler.java   
@Override
public void onLog(LogEntry logEntry) {

  final LoggingEvent loggingEvent = new LoggingEvent();
  loggingEvent.setTimeStamp(logEntry.getTimestamp());
  loggingEvent.setLoggerName(logEntry.getLoggerName());
  loggingEvent.setLevel(Level.valueOf(logEntry.getLogLevel().name()));
  loggingEvent.setThreadName(logEntry.getThreadName());
  Object [] formatObjects = new Object[] {logEntry.getHost(),
    getSimpleClassName(logEntry.getSourceClassName()),
    logEntry.getSourceMethodName(),
    logEntry.getFileName(),
    logEntry.getLineNumber(),logEntry.getMessage()};
  loggingEvent.setMessage(MESSAGE_FORMAT.get().format(formatObjects));

  // Prints the throwable and stack trace.
  LogThrowable logThrowable = logEntry.getThrowable();
  if (logThrowable != null) {
    loggingEvent.setThrowableProxy(new ThrowableProxy(setThrowable(logThrowable)));
  }

  if (logger instanceof Logger) {
    ((Logger) logger).callAppenders(loggingEvent);
  } else {
    logger.info("Logger is not instance of ch.qos.logback.classic.Logger. Logger event is: {}", loggingEvent);
  }
}
项目:Blizcord    文件:Log.java   
private static void setupOwnLogger() {
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

    logger = (Logger) LoggerFactory.getLogger(Values.BOT_NAME);
    ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<>();
    consoleAppender.setContext(lc);
    consoleAppender.setName("console");
    LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();

    PatternLayout layout = new PatternLayout();
    layout.setPattern("[%d{HH:mm:ss}] [%level] [%logger] %msg%n");
    layout.setContext(lc);
    layout.start();
    encoder.setLayout(layout);

    consoleAppender.setEncoder(encoder);
    consoleAppender.start();

    // disable default appender
    logger.setAdditive(false);

    // enable custom console appender
    logger.addAppender(consoleAppender);

    // set logging level
    if(a.isDebug()) {
        logger.setLevel(Level.DEBUG);
    } else {
        logger.setLevel(Level.INFO);
    }
}
项目:incubator-plc4x    文件:IsoOnTcpProtocolTest.java   
/**
 * If logging is set to `DEBUG` then a hexdump of the entire captured packet
 * should be logged
 */
@Test
@Tag("fast")
public void decodeLogPacketIfTraceLogging() {
    // Setup the mock logger.
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    Appender mockAppender = mock(Appender.class);
    when(mockAppender.getName()).thenReturn("MOCK");
    root.addAppender(mockAppender);
    // Save the current default logging level
    Level defaultLevel = root.getLevel();
    try {
        // Change the logging to TRACE.
        root.setLevel(Level.TRACE);

        // Do some deserialization
        EmbeddedChannel channel = new EmbeddedChannel(new IsoOnTcpProtocol());
        channel.writeInbound(Unpooled.wrappedBuffer(new byte[]{IsoOnTcpProtocol.ISO_ON_TCP_MAGIC_NUMBER,
            (byte) 0x00, (byte) 0x00, (byte) 0x0D,
            (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09}));
        channel.checkException();
        Object obj = channel.readInbound();
        assertNotNull(obj, "Something should have been decoded");

        // Check that the packet dump was logged.
        verify(mockAppender).doAppend(argThat(argument ->
            ((LoggingEvent) argument).getFormattedMessage().contains("Got Data: 0300000d010203040506070809")));
    } finally {
        // Reset the log level to the default.
        root.setLevel(defaultLevel);
    }
}
项目:heat    文件:LoggingUtils.java   
private void log(String mode, String message) {
    try {
        org.slf4j.Logger logger = LoggerFactory.getLogger(getCurrentClass(THREAD_COUNT_LOG_LEVEL));
        Class[] cArg = new Class[1];
        cArg[0] = String.class;
        Method loggerMethod = logger.getClass().getMethod(mode, cArg);
        loggerMethod.invoke(logger, getTestCaseLogDetails() + " -- " + message);
    } catch (Exception oEx) {
        throw new HeatException(getExceptionDetails() + oEx.getClass()
                + " / cause: '" + oEx.getCause() + "' / message: '" + oEx.getLocalizedMessage() + "'");
    }
}
项目:play-graylog2    文件:Graylog2Component.java   
@Inject
public Graylog2Impl(Configuration config) {
    String canonicalHostName;
    try {
        canonicalHostName = config.getString(
                "graylog2.appender.sourcehost",
                InetAddress.getLocalHost().getCanonicalHostName()
        );
    } catch (UnknownHostException e) {
        canonicalHostName = "unknown";
    }

    accessLogEnabled = config.getBoolean("graylog2.appender.access-log", false);

    final GelfConfiguration gelfConfiguration = getGelfConfiguration(config);

    GelfTransport transport = GelfTransports.create(gelfConfiguration);

    final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    final Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);

    gelfClientAppender = new GelfClientAppender(transport, canonicalHostName);

    gelfClientAppender.setContext(lc);

    gelfClientAppender.start();

    rootLogger.addAppender(gelfClientAppender);
}
项目:ping    文件:CommandLineParserTest.java   
@After
public void after () {
    System.setOut(null);
    System.setErr(null);

    Logger root = (Logger) LoggerFactory.getLogger(ROOT_LOGGER_NAME);
    root.setLevel(INFO);

    Locale.setDefault(defaultLocale);
}
项目:wngn-jms-kafka    文件:KafkaAppenderIT.java   
@Test
public void testLogging() throws InterruptedException {

    final Logger logger = loggerContext.getLogger("ROOT");

    unit.start();

    assertTrue("appender is started", unit.isStarted());

    for (int i = 0; i<1000; ++i) {
        final LoggingEvent loggingEvent = new LoggingEvent("a.b.c.d", logger, Level.INFO, "message"+i, null, new Object[0]);
        unit.append(loggingEvent);
    }

    final Properties consumerProperties = new Properties();
    consumerProperties.put("metadata.broker.list", kafka.getBrokerList());
    consumerProperties.put("group.id", "simple-consumer-" + new Random().nextInt());
    consumerProperties.put("auto.commit.enable","false");
    consumerProperties.put("auto.offset.reset","smallest");
    consumerProperties.put("zookeeper.connect", kafka.getZookeeperConnection());
    final kafka.consumer.ConsumerConfig consumerConfig = new kafka.consumer.ConsumerConfig(consumerProperties);
    final ConsumerConnector javaConsumerConnector = Consumer.createJavaConsumerConnector(consumerConfig);
    final KafkaStream<byte[], byte[]> log = javaConsumerConnector.createMessageStreamsByFilter(new Whitelist("logs"),1).get(0);
    final ConsumerIterator<byte[], byte[]> iterator = log.iterator();

    for (int i=0; i<1000; ++i) {
        final String messageFromKafka = new String(iterator.next().message(), UTF8);
        assertThat(messageFromKafka, Matchers.equalTo("message"+i));
    }


}
项目:secondbase    文件:SecondBaseLogger.java   
/**
 * Set up logback logging for service and request logs. We use only ONE appender here to write
 * normal log lines to stdout for both types. Logging context is set from the keys and values
 * parameters. They must be corresponding in length and all elements must be non-null and
 * non-empty. However, the request logger is set up slightly differently. To guarantee that
 * everything works as expected this method must be called with the fully qualified class name
 * of the request logger that will be used in jetty.
 * @param keys to add to all log lines
 * @param values to add to all log lines
 * @param requestLoggerName the request logger class name
 * @param json true for json output, false for plain test
 */
 public static void setupLoggingStdoutOnly(
        final String[] keys,
        final String[] values,
        final String requestLoggerName,
        final boolean json) {
    if(!parametersOk(keys, values)) {
        throw new IllegalArgumentException(
                "Context keys and/or values are not properly formatted.");
    }
    final LoggerContext loggerContext = getLoggerContext(keys, values);
    final Appender<ILoggingEvent> consoleAppender = json
            ? createJsonConsoleAppender(SERVICE_CONSOLE_APPENDER, loggerContext, true)
            : createPatternLayoutConsoleAppender(SERVICE_CONSOLE_APPENDER, loggerContext, true);

    // specifically cast to logback version so we set it up
    final Logger rootLogger = (Logger) LoggerFactory.getLogger(
            org.slf4j.Logger.ROOT_LOGGER_NAME);
    rootLogger.addAppender(consoleAppender);
    rootLogger.setLevel(LOG_LEVEL);

    if (!Strings.isNullOrEmpty(requestLoggerName)) {
        final Logger requestLogger = (Logger) LoggerFactory.getLogger(requestLoggerName);
        requestLogger
                .addAppender(json
                        ? createJsonConsoleAppender(
                                REQUESTLOG_CONSOLE_APPENDER, loggerContext, false)
                        : createPatternLayoutConsoleAppender(
                                REQUESTLOG_CONSOLE_APPENDER, loggerContext, false));
        requestLogger.setAdditive(false);
        requestLogger.setLevel(LOG_LEVEL);
    }
}