• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you can specify it that way no.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20971
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to perform any initialisation at all, it will just 'work out of the box'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic