title: What is the correct way of logging in an xml from two different classes ? For now I get an error in the xml produced
body: <p>By default the code :</p>
  
  <pre><code>class Tester {
    public static void main(String args[]) throws IOException{
      Logger logger = Logger.getLogger(Tester.class.getName());
      FileHandler fHandler = new FileHandler("LOGGED.xml",true);
      logger.addHandler(fHandler);
      logger.log(Level.INFO,"This is an info log message");
      fHandler.close();
    }
  }
  </code></pre>
  
  <p>produces a <code>xml</code> of the type :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1252" standalone="no"?&gt;
  &lt;!DOCTYPE log SYSTEM "logger.dtd"&gt;
  &lt;log&gt;
    &lt;record&gt;
      &lt;date&gt;2013-02-03T08:16:37&lt;/date&gt;
      &lt;millis&gt;1359859597763&lt;/millis&gt;
      &lt;sequence&gt;0&lt;/sequence&gt;
      &lt;logger&gt;Tester&lt;/logger&gt;
      &lt;level&gt;INFO&lt;/level&gt;
      &lt;class&gt;Tester&lt;/class&gt;
      &lt;method&gt;main&lt;/method&gt;
      &lt;thread&gt;1&lt;/thread&gt;
      &lt;message&gt;This is an info log message&lt;/message&gt;
   &lt;/record&gt;
  &lt;/log&gt;
  </code></pre>
  
  <p>But if I try to append to the <em>xml</em> produced above, by the following code :</p>
  
  <pre><code>class Tester_1{
  public static void main(String args[]) {
      try {
          Logger logger = Logger.getLogger(Tester_1.class.getName());
          FileHandler fHandler = new FileHandler("LOGGED.xml",true);
          logger.addHandler(fHandler);
          logger.log(Level.INFO,"This is a custom message from my own formatter !");
          fHandler.close();
      }catch(Exception exc) {
          exc.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>it appends the following to the previous <em>xml</em> produced :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1252" standalone="no"?&gt;
  &lt;!DOCTYPE log SYSTEM "logger.dtd"&gt;
  &lt;log&gt;
   &lt;record&gt;
     &lt;date&gt;2013-02-03T08:16:51&lt;/date&gt;
     &lt;millis&gt;1359859611306&lt;/millis&gt;
     &lt;sequence&gt;0&lt;/sequence&gt;
     &lt;logger&gt;Tester_1&lt;/logger&gt;
     &lt;level&gt;INFO&lt;/level&gt;
     &lt;class&gt;Tester_1&lt;/class&gt;
     &lt;method&gt;main&lt;/method&gt;
     &lt;thread&gt;1&lt;/thread&gt;
     &lt;message&gt;This is a custom message from my own formatter !&lt;/message&gt;
   &lt;/record&gt;
  &lt;/log&gt;
  </code></pre>
  
  <p>and when I try opening this <em>xml</em> in the browser,I get the following error :</p>
  
  <pre><code>This page contains the following errors:
  
  error on line 27 at column 6: XML declaration allowed only at the start of the document
  </code></pre>
  
  <p>What do I do to avoid the statements :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1252" standalone="no"?&gt;
  &lt;!DOCTYPE log SYSTEM "logger.dtd"&gt;
  </code></pre>
  
  <p>two times ? I want <em>xml</em> with just the <code>log</code> tag appended to the end of the xml.</p>