You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by gerold kathan <ge...@kathan.at> on 2007/02/24 14:29:42 UTC

Re: How to use log4j (log4j.xml) and Maven and Junit??

hi - i have exactly the same issue:
* i did what you mentioned (1-3)
* yes it copies the log4j.xml to the right place under src/test/
* BUT the testrunner the complains that it cannot find the file under the 
projects root directory (where also the pom.xml sits)

log4j:ERROR Could not parse file [log4j.xml].
java.io.FileNotFoundException: D:\_devel\_java\_workspace\springtest\log4j.xml 

=> but he should look under

D:\_devel\_java\_workspace\springtest\target\test-classes\log4j.xml


=> the call from the java source to the log4j.xml looks like
    static
    {
        DOMConfigurator.configure("log4j.xml");
        logger = Logger.getLogger(AppTest.class);
    }


strange - any hints on that ?




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: How to use log4j (log4j.xml) and Maven and Junit??

Posted by Jacob Kjome <ho...@visi.com>.
At 07:29 AM 2/24/2007, you wrote:
 >hi - i have exactly the same issue:
 >* i did what you mentioned (1-3)
 >* yes it copies the log4j.xml to the right place under src/test/
 >* BUT the testrunner the complains that it cannot find the file under the
 >projects root directory (where also the pom.xml sits)
 >
 >log4j:ERROR Could not parse file [log4j.xml].
 >java.io.FileNotFoundException: 
D:\_devel\_java\_workspace\springtest\log4j.xml
 >
 >=> but he should look under
 >
 >D:\_devel\_java\_workspace\springtest\target\test-classes\log4j.xml
 >
 >
 >=> the call from the java source to the log4j.xml looks like
 >    static
 >    {
 >        DOMConfigurator.configure("log4j.xml");
 >        logger = Logger.getLogger(AppTest.class);
 >    }
 >
 >
 >strange - any hints on that ?
 >

Not strange at all.  You are giving a relative file path which will 
be resolved to the directory where the JVM started, which is likely 
the directory of the pom.xml.  Why are you manually configuring Log4j 
anyway?  Just copy log4j.xml to "test-classes" and let Log4j's 
autoconfiguration perform the configuration.  There is no reason to 
manually call configure().


Jake



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org