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


Java Logger.setLevel方法代码示例

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


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

示例1: configure

import ch.qos.logback.classic.Logger; //导入方法依赖的package包/类
@Override
public void configure(LoggerContext lc) {
  addInfo("Setting up robot logging configuration.");

  ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
  ca.setContext(lc);
  ca.setName("console");
  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();

  Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
  rootLogger.addAppender(ca);
  rootLogger.setLevel(Level.DEBUG);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:25,代码来源:LoggingConfigurator.java

示例2: 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

示例3: 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

示例4: setLogLevel

import ch.qos.logback.classic.Logger; //导入方法依赖的package包/类
/**
 * This method sets the log level (logback).
 */
public void setLogLevel() {
    logLevel = System.getProperty("logLevel", LOG_LEVEL_INFO);
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    Level logLevelSetting;
    switch (logLevel.toLowerCase()) {
    case LOG_LEVEL_ERROR:
        logLevelSetting = Level.ERROR;
        break;
    case LOG_LEVEL_WARN:
        logLevelSetting = Level.WARN;
        break;
    case LOG_LEVEL_ALL:
        logLevelSetting = Level.ALL;
        break;
    case LOG_LEVEL_TRACE_LOG:
        logLevelSetting = Level.TRACE;
        break;
    case LOG_LEVEL_INFO:
        logLevelSetting = Level.INFO;
        break;
    case LOG_LEVEL_DEBUG:
        logLevelSetting = Level.DEBUG;
        break;
    default:
        logLevelSetting = Level.INFO;
        break;
    }
    root.setLevel(logLevelSetting);
}
 
开发者ID:HotelsDotCom,项目名称:heat,代码行数:33,代码来源:LoggingUtils.java

示例5: springLogging

import ch.qos.logback.classic.Logger; //导入方法依赖的package包/类
@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();
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:9,代码来源:HttpLoggingConfig.java

示例6: getLogger

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

示例7: configure

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

示例8: configure

import ch.qos.logback.classic.Logger; //导入方法依赖的package包/类
@Override
public void configure(LoggerContext loggerContext) {
    addInfo("Setting up default configuration.");

    DefaultConsoleAppender consoleAppender = new DefaultConsoleAppender();
    consoleAppender.setContext(loggerContext);
    consoleAppender.setName("CONSOLE");
    consoleAppender.start();

    Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.INFO);
    rootLogger.addAppender(consoleAppender);
}
 
开发者ID:symphoniacloud,项目名称:lambda-monitoring,代码行数:14,代码来源:DefaultLogbackConfigurator.java

示例9: doInitializer

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

示例10: decodeLogPacketIfTraceLogging

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

示例11: TestLogAppender

import ch.qos.logback.classic.Logger; //导入方法依赖的package包/类
public TestLogAppender() {
    sb = new StringBuilder();
    logger = (Logger) LoggerFactory.getLogger("com.intuit.karate");
    setName("karate-test");
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    setContext(lc);
    encoder = new PatternLayoutEncoder();
    encoder.setPattern("%msg");
    encoder.setContext(context);
    encoder.start();
    start();
    logger.addAppender(this);
    logger.setLevel(Level.DEBUG);
}
 
开发者ID:intuit,项目名称:karate,代码行数:15,代码来源:TestLogAppender.java

示例12: TextAreaLogAppender

import ch.qos.logback.classic.Logger; //导入方法依赖的package包/类
public TextAreaLogAppender(TextArea textArea) {
    this.textArea = textArea;
    logger = (Logger) LoggerFactory.getLogger("com.intuit.karate");
    setName("karate-ui");
    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);
    logger.setLevel(Level.DEBUG);
}
 
开发者ID:intuit,项目名称:karate,代码行数:15,代码来源:TextAreaLogAppender.java

示例13: main

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

示例14: setupOwnLogger

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

示例15: setupOtherLoggers

import ch.qos.logback.classic.Logger; //导入方法依赖的package包/类
private static void setupOtherLoggers() {
	Logger lavaplayerLogger = (Logger) LoggerFactory.getLogger("com.sedmelluq.discord.lavaplayer");
	Logger jdaLogger = (Logger) LoggerFactory.getLogger("net.dv8tion.jda");

	if(a.isDebug()) {
		// set JDA logging to DEBUG
		jdaLogger.setLevel(Level.DEBUG);
		// set lavaplayer logging to DEBUG
		lavaplayerLogger.setLevel(ch.qos.logback.classic.Level.DEBUG);
		// set JNativeHook logging level to WARNING
		NativeKeyListener.setLevel(java.util.logging.Level.WARNING);
	} else {
		if(a.isGui()) {
			// disable JDA logging (only ERROR)
			jdaLogger.setLevel(Level.ERROR);
			// disable lavaplayer logging
			lavaplayerLogger.setLevel(ch.qos.logback.classic.Level.OFF);
			// set JNativeHook logging level to OFF
			NativeKeyListener.setLevel(java.util.logging.Level.OFF);
		} else {
			// set JDA logging to WARN
			jdaLogger.setLevel(Level.WARN);
			// set lavaplayer logging to WARN
			lavaplayerLogger.setLevel(ch.qos.logback.classic.Level.WARN);
			// set JNativeHook logging level to WARNING
			NativeKeyListener.setLevel(java.util.logging.Level.WARNING);
		}
	}
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:30,代码来源:Log.java


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