title: Log4j configureAndWatch() spawning thousands of threads
body: <p>So we have our J2EE application using Log4j like this</p>
  
  <pre><code>public class CustomerController 
  {
      private static Logger logger = Logger.getLogger(CustomerController.class);
  
       public CustomerService customerservice = null;
  
       public CustomerController() throws Exception 
       {
             PropertyConfigurator.configureAndWatch("c:\log4j.property", 50000);
  
              customerservice = ServiceManagerSingleton.getCustomerServiceInstance();
       }
  }
  </code></pre>
  
  <p>This way we can change the log-level realtime. Very handy. Most of our classes are set up just like this controller. We use the singleton-pattern so that we only have one instance of eash class; one call to PropertyConfigurator.configureAndWatch() for each class, once. </p>
  
  <p>The problem: About twice a week our appserver dies and creates a heapdump. Using Heap Analyzer from IBM we can see that there seems to be alot of threads related to Log4j:</p>
  
  <pre><code> 808 (0%) [200] 9 org/apache/log4j/PropertyWatchdog 0x14282ad8
  </code></pre>
  
  <p>About 30,000 in total. So this is probably the reason for the sudden crash. </p>
  
  <ol>
  <li>Are we setting this up correctly? </li>
  <li>What happens to all those threads when the EAR is redeployed? </li>
  </ol>