本文整理汇总了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);
}
示例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();
}
}
}
示例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));
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
}