我正在编写一个使用log4j作为其日志记录工具的应用程序。我试图将它连接到Sentry.io跟踪,但每当我尝试记录某些内容时,我会得到以下异常:
2016-09-27 13:38:13 WARN EventBuilder$HostnameCache:625 - Localhost
hostname lookup failed, keeping the value 'unavailable'
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.getsentry.raven.event.EventBuilder$HostnameCache.updateCache(EventBuilder.java:620)
at com.getsentry.raven.event.EventBuilder$HostnameCache.getHostname(EventBuilder.java:606)
at com.getsentry.raven.event.EventBuilder.autoSetMissingValues(EventBuilder.java:90)
at com.getsentry.raven.event.EventBuilder.build(EventBuilder.java:360)
at com.getsentry.raven.log4j.SentryAppender.buildEvent(SentryAppender.java:252)
at com.getsentry.raven.log4j.SentryAppender.append(SentryAppender.java:174)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.fatal(Category.java:382)
at com.pikmy.core.PikmyServer.main(PikmyServer.java:21)
我已经设置了我的log4j.xaml文件,就像在此处提供的文档中所描述的那样: https://sentry.io/pikmy-ltd/pikmy-api/settings/install/java-log4j/
向Sentry发送数据可能会出现什么问题?
更多信息:
log4j.xml文件:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="sentry" class="com.getsentry.raven.log4j.SentryAppender">
<param name="dsn" value="SENTRY_URL_HERE"/>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="levelMin" value="WARN"/>
</filter>
</appender>
<root>
<priority value="info" />
<appender-ref ref="sentry" />
</root>
我用一个简单的例外测试了日志记录:
static Logger log = Logger.getLogger(PikmyServer.class.getName());
try {
throw new UnsupportedOperationException();
} catch (Exception ex) {
log.fatal("Test", ex);
}
Log4j.xml放在资源中,因此记录器默认获取配置。
答案 0 :(得分:1)
显然,这是本地阻止互联网配置的问题。我将互联网信息源从一个开放的连接切换到一个私有信息,一切都神奇地开始工作。