aspose file tools*
The moose likes Java in General and the fly likes Can't find logj4.properties using netbeans, hibernate and glassfish Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can Watch "Can New topic
Author

Can't find logj4.properties using netbeans, hibernate and glassfish

Alvaro Reinoso
Greenhorn

Joined: Feb 14, 2012
Posts: 4
Hi,

I'm getting this error when I run my web application using netbeans and glassfish:



I really need to debug the hibernate queries. Log4j.properties file is configured, but it seems my app can't find it.

This the class where I initialize the logger:



I want to store logj4.properties in cfg folder. Even if I try PropertyConfigurator.configure("logj4.properties") (also hardcoding the path) and put the file in src folder, it can't find.

Any help would be really useful.

Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

The normal way to configure log4j is to put the log4j.properties file in the classpath. That's all you need to do... unless you are trying to configure something which isn't in the properties file. Your code doesn't do anything like that, so you should remove it entirely.

As for putting it into the classpath, your Netbeans cfg directory definitely isn't going to be the right place. In real life your Glassfish server won't care about Netbeans at all, or even know about it. I try to arrange things so that my log4j.properties file gets put into the web application's /WEB-INF/classes directory. I assume Netbeans can arrange that for you but (not being a Netbeans user) I can't tell you how.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't find logj4.properties using netbeans, hibernate and glassfish