本文整理汇总了Java中ch.qos.logback.classic.Logger.getLevel方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.getLevel方法的具体用法?Java Logger.getLevel怎么用?Java Logger.getLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.Logger
的用法示例。
在下文中一共展示了Logger.getLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}