This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Log4j tries to configure itself by searching in its classpath for log4j.properties or log4j.xml file. If you place the log4j.xml file in the classpath of the application then you need not write any code to read the file. You can start using the logger as follows in your code:
However if you still want to read/configure the log4j config file yourself in the application then have a look at the configure() method available on DOMConfigurator