Reputation: 43
I am writing an app that is using log4j as its logging tool. I tried to hook it up to Sentry.io tracking, but I get the following exception each time when I try to log something:
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)
I have set up my log4j.xaml file just like it was described in the documentation present here: https://sentry.io/pikmy-ltd/pikmy-api/settings/install/java-log4j/
What could be the possible problem with sending data to Sentry?
More information:
The log4j.xml file:
<?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>
I tested the logging with a simple exception like this:
static Logger log = Logger.getLogger(PikmyServer.class.getName());
try {
throw new UnsupportedOperationException();
} catch (Exception ex) {
log.fatal("Test", ex);
}
Log4j.xml is placed in the resources, so the logger gets the configuration by default.
Upvotes: 1
Views: 1773
Reputation: 43
Apparently, this was a problem with the internet configuration being blocked locally. I switched the internet source from an open connection to a private one and everything just magically started working.
Upvotes: 2