本文整理匯總了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);
}
}