这是可能如此简单,但我已经浪费了很多时间来寻找任何解决办法。
我有过
package net.rubyeye.xmemcached;
...
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
public class XMemcachedClient implements XMemcachedClientMBean, MemcachedClient {
private static final Logger log = LoggerFactory
.getLogger(XMemcachedClient.class);
....使用Log4j,我可以从获得所有日志。
我试过
log4j.logger.net.rubyeye.xmemcached.XMemcachedClient=All, xmemcachedLog
log4j.appender.xmemcachedLog=org.apache.log4j.RollingFileAppender
log4j.appender.xmemcachedLog.File=${karaf.data}/log/spring/xmemcachedLog.log
log4j.appender.xmemcachedLog.ImmediateFlush=true
log4j.appender.xmemcachedLog.maxFileSize = 10MB
log4j.appender.xmemcachedLog.maxBackupIndex = 10
log4j.appender.xmemcachedLog.layout=org.apache.log4j.PatternLayout
log4j.appender.xmemcachedLog.layout.ConversionPattern=%d{dd-MM-yyyy_HH:mm:ss} %-5p [%t] - %m%n但我什么都没得到。我想获得关于异常的信息,这是我在第1335行得到的。
key = this.preProcessKey(key);实际上,我想要准确地记录这门课并不重要。在我的应用程序中,我还有其他类具有LoggerFactory.getLogger(.);
主要问题是如何从Logger = LoggerFactory .getLogger(SomeClass.class);获取日志
现在,我的rootLogger看起来
# Root logger
log4j.rootLogger=info, out, sift, osgi:VmLogAppender
log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer发布于 2019-05-15 15:15:19
我的伐木机没问题。我只是没有任何log.error()或log.smth(),所以我的文件中没有任何行。
因此,例如,在XMemcachedClient内部的那个方法中,它可以工作。
public void setTimeoutExceptionThreshold(int timeoutExceptionThreshold) {
if (timeoutExceptionThreshold <= 0) {
throw new IllegalArgumentException(
"Illegal timeoutExceptionThreshold value "
+ timeoutExceptionThreshold);
}
if (timeoutExceptionThreshold < 100) {
log.warn("Too small timeoutExceptionThreshold value may cause connections disconnect/reconnect frequently.");
}
this.timeoutExceptionThreshold = timeoutExceptionThreshold;
}它向我展示了“过小的timeoutExceptionThreshold值可能导致连接断开/重新连接频繁。”当timeoutExceptionThreshold < 100时,在${karaf.data}/log/spring/xmemacedLog.log中的
发布于 2019-05-15 14:04:47
如果您在java应用程序中,您应该有一个决定是否显示日志的logback.xml。
尝试将这一行代码添加到其中:
<logger name="net.rubyeye.xmemcached" level="DEBUG"/>它将激活此包中所有类的调试日志。如果它仍然不能工作,可能您的类路径中没有该文件,您可能必须将它添加到jvm参数中。
https://stackoverflow.com/questions/56150574
复制相似问题