I get the following (and other statuses) printed to stdout on startup on a box 
running inside Amazon VPC. 

04:55:44,918 |-ERROR in ch.qos.logback.core.util.ContextUtil@5328f6ee - Failed 
to get local hostname java.net.UnknownHostException: ip-10-0-4-173: 
ip-10-0-4-173
        at java.net.UnknownHostException: ip-10-0-4-173: ip-10-0-4-173
        at      at java.net.InetAddress.getLocalHost(InetAddress.java:1426)
        at      at 
ch.qos.logback.core.util.ContextUtil.getLocalHostName(ContextUtil.java:32)
        at      at 
ch.qos.logback.core.util.ContextUtil.addHostNameAsProperty(ContextUtil.java:41)
        at      at 
ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:56)
        at      at 
ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276)
        at      at 
ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148)
        at      at 
ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130)
        at      at 
ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
        at      at 
ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157)
        at      at 
ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143)
        at      at 
ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106)
        at      at 
ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56)
        at      at 
ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
        at      at 
ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
        at      at 
org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
        at      at 
org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:54)
        at      at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
        at      at 
org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
        at      at 
org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
        at      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
        at      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)

This is, unfortunately, breaking the tool that is running this code since it 
uses stdout to pipe data to other processes. 
(Seehttp://jira.qos.ch/browse/LOGBACK-292 for more on the fact that statuses 
are output to stdout even in the case of this automatic error-triggered output.)

My config file is:

<configuration>

 <appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
   <encoder>
     <pattern>%d [%thread] %-5level %logger{36} - %msg%n</pattern>
   </encoder>
   <target>System.err</target>
 </appender>

 <root level="WARN">
   <appender-ref ref="STDERR"/>
 </root>
</configuration>

This config works, and all of the other statuses are just INFO's. 

I'm not using the hostname anywhere, and I do not care about it at all, so it's 
unfortunate that Logback seems to insist on complaining about it when I'm not 
actually using it.

The "HOSTNAME" property is set presumably so that the property can be used 
during configuration. 

ContextBase#getProperty(String) already has a special case in it:

public String getProperty(String key) {
   if (CONTEXT_NAME_KEY.equals(key))
     return getName();

   return (String) this.propertyMap.get(key);
}

What do you think about having another special case added to getProperty to 
lazy-load the hostname?
_______________________________________________
Logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to