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


Java Logger类代码示例

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


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

示例1: run

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
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();
        }
    }
}
 
开发者ID:spinscale,项目名称:maxcube-java,代码行数:26,代码来源:Cli.java

示例2: disableAllOntopLogger

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
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);
}
 
开发者ID:onprom,项目名称:onprom,代码行数:19,代码来源:XESLogExtractorExperimental.java

示例3: warmUp

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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);
}
 
开发者ID:ARMmbed,项目名称:java-coap,代码行数:20,代码来源:ServerBenchmark.java

示例4: enableAllOntopLogger

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
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);
}
 
开发者ID:onprom,项目名称:onprom,代码行数:19,代码来源:XESLogExtractor.java

示例5: init

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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());
}
 
开发者ID:webfolderio,项目名称:cdp4j,代码行数:23,代码来源:TestAll.java

示例6: setUp

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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));
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:23,代码来源:UnknownMethodAlgorithmLoggerTest.java

示例7: decide

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:26,代码来源:LogbackMetrics.java

示例8: warmUp

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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);
}
 
开发者ID:ARMmbed,项目名称:java-coap,代码行数:21,代码来源:ServerBenchmarkBase.java

示例9: testTcpSender

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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"));
}
 
开发者ID:serioussam,项目名称:syslogappender,代码行数:18,代码来源:SyslogAppenderTest.java

示例10: testTlsSender

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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"));
}
 
开发者ID:serioussam,项目名称:syslogappender,代码行数:18,代码来源:SyslogAppenderTest.java

示例11: configure

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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);
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:19,代码来源:LogConfigurator.java

示例12: apply

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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);
      }
    }
  };
}
 
开发者ID:mustaine,项目名称:logcapture,代码行数:18,代码来源:LogCaptureRule.java

示例13: warmUp

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
@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);
}
 
开发者ID:ARMmbed,项目名称:java-coap,代码行数:23,代码来源:ParsingBenchmark.java

示例14: configureInMemoryLogging

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
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);
}
 
开发者ID:spinscale,项目名称:maxcube-java,代码行数:26,代码来源:Cli.java

示例15: log

import ch.qos.logback.classic.Logger; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:roshakorost,项目名称:Phial,代码行数:36,代码来源:PhialLogger.java


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