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