title: duplicate lines in java applet when using log4j
body: <p>I'm trying to use log4j in an applet, but every time I refresh the page in the browser (to restart the applet) I get duplicated lines of output in the java console. The number of times the output is duplicated increases after each refresh.</p>
  
  <p>This code reproduces the effect:</p>
  
  <pre><code>public class HelloWorldApplet extends JApplet {
      static Logger logger = Logger.getLogger(HelloWorldApplet.class);
      public void init() {
          BasicConfigurator.configure();
          logger.info("Hello log4j");
          System.out.println("Hello System.out");
      }
  }
  </code></pre>
  
  <p>And this is the output that I'm seeing:</p>
  
  <pre><code>0 [thread applet-HelloWorldApplet.class-26] INFO HelloWorldApplet  - Hello log4j
  Hello System.out
  &lt;refresh&gt;
  1987 [thread applet-HelloWorldApplet.class-27] INFO HelloWorldApplet  - Hello log4j
  1987 [thread applet-HelloWorldApplet.class-27] INFO HelloWorldApplet  - Hello log4j
  Hello System.out
  &lt;again&gt;
  3156 [thread applet-HelloWorldApplet.class-28] INFO HelloWorldApplet  - Hello log4j
  3156 [thread applet-HelloWorldApplet.class-28] INFO HelloWorldApplet  - Hello log4j
  3156 [thread applet-HelloWorldApplet.class-28] INFO HelloWorldApplet  - Hello log4j
  Hello System.out
  </code></pre>
  
  <p>Clearing the classloader cache fixes it, and I know I need to clear the classloader cache to actually reload an applet, but sometimes I just want to restart it, especially when debugging. So I would like to understand:</p>
  
  <ol>
  <li>Why is this happening?</li>
  <li>Is there a way to prevent it?</li>
  </ol>
  
  <p>Thanks!</p>