title: How can I change localhost.localdomain in the messages written by Log4j to the Linux syslog
body: <p>I'm writing messages to the Linux syslog using Log4j and its SyslogAppender. The outputted messages look like this:</p>
  
  <pre><code>Oct 12 09:06:03 localhost.localdomain 3364 [Thread-5] INFO TEST MESSAGE MyApplicationLogger - This is my message
  </code></pre>
  
  <p>I would like to replace localhost.localdomain with the name of the server running the application but can't seem to figure out how. Here's my configuration file, in case it's useful:</p>
  
  <pre><code>log4j.logger.MyApplicationLogger=INFO, SyslogAppender
  log4j.appender.SyslogAppender=org.apache.log4j.net.SyslogAppender
  log4j.appender.SyslogAppender.syslogHost=localhost
  log4j.appender.SyslogAppender.Facility=USER
  log4j.appender.SyslogAppender.layout=org.apache.log4j.PatternLayout
  log4j.appender.SyslogAppender.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n
  log4j.appender.SyslogAppender.source=My Application
  </code></pre>
  
  <p><strong>Edit</strong>: the computer name is configured on the server and the hostname command returns the following:</p>
  
  <pre><code>$ hostname
  server12
  </code></pre>
  
  <p>I do notice however that the first line of the hosts file is </p>
  
  <pre><code>127.0.0.1   localhost.localdomain localhost
  </code></pre>
  
  <p>However I'm hesitant to change this.</p>