File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Can the path of lo4j properties file be relative to classpath? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Can the path of lo4j properties file be relative to classpath?" Watch "Can the path of lo4j properties file be relative to classpath?" New topic
Author

Can the path of lo4j properties file be relative to classpath?

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
web.xml


log4j.properties



When I give "classpath:resources/log4j.properties" , it takes the actual path and gives file not found exception.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I don't think you can specify it that way no.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Thanks Martijn. I think the only way is if I use my implementation for that. But it is more practical to be in that way because nowadays in many java technologies it's been implemented in that way for example Spring. I define in this way.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

But log4j will look for the log4j.properties file in the classpath anyway, without you having to do anything at all. I don't see any benefit in what you're asking for there, just so you can put the file in a different directory. You don't even need an init-param if you allow log4j to work in the normal way.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Paul, I tried putting the log4j.properties file into classpath i.e. under classes folder and pass only the file name like,
But it doesn't work. So how do you suggest it?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You don't need to perform any initialisation at all, it will just 'work out of the box'
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can the path of lo4j properties file be relative to classpath?