title: Best Practice on Configuring Log4j Properties Path
body: <p>I am using Log4j in my applications. <code>log4j.properties</code> is placed in a Jar which is in classpath. This configuration file is being used and works fine most of the times. </p>
  
  <p>But sometimes, the logging statements that are getting generated are not as per the configuration file. </p>
  
  <p>My understanding is, this is because the properties file is fetched from the class path. Whatever first properties file is, is fetched and used by log4j. Thus sometimes we get the logging statements different from what is configured in properties file.</p>
  
  <p>In case, the above reason is true, then I think, we need to specify the configuration file specifically by one of the following ways:</p>
  
  <ol>
  <li>Specify using System Properties :
  -Dlog4j.configuration=log4j.properties</li>
  <li>Initializing Log4jInit servlet.</li>
  </ol>
  
  <p>Please suggest which could be the better approach.</p>