Meaningless Drivel is fun!*
The moose likes IDEs, Version Control and other tools and the fly likes log4j in eclipse enterprise application project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "log4j in eclipse enterprise application project" Watch "log4j in eclipse enterprise application project" New topic
Author

log4j in eclipse enterprise application project

Shane Lee
Ranch Hand

Joined: Mar 19, 2005
Posts: 63
Eclipse 3.3.1
ObjectWeb Lomboz for JavaEE Development Version: 3.3
Log4j 1.2.15
Java JEE1.4

I am trying to setup logging in my project correctly for my enterprise application.
I have three modules:
Application client
EJB
Utility

These are all module dependencies for my root project folder.

So if i have logging in each module where does the log4j.properties file go? Does it have to go into the src directory of each project or can it be somehow placed in the root folder and delegated/linked to the underlying modules?

Thanks,
Shane.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

The log4j.properties file must appear in the classpath. If "client" and "ejb" both depend on "util", then by placing it in "util" you should be covered.


JBoss In Action
Shane Lee
Ranch Hand

Joined: Mar 19, 2005
Posts: 63
Yea client and ejb depend on my util project as a j2ee module dependencie, so if my util project includes log4j.properties it will work. I will test myself to see.

Thanks,
Shane.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

The key word here is "classpath".

Your client will have one classpath, as defined in the applet tag (assuming it's an applet).

The EJB has its own internal classpath, which has it's container classpath appended to it.

The Utility will also have its own classpath.

Expect to need a log4j properties (or log4j.xml) in each one. It may be an identical copy of the other 2 log4j files, or it may be customized for the component in question, but each classpath must include a log4j properties file, located at the root level (for example, in the WEB-INF/classes directory of a WAR).


Customer surveys are for companies who didn't pay proper attention to begin with.
Shane Lee
Ranch Hand

Joined: Mar 19, 2005
Posts: 63
Thanks tim, that is the way i have it setup, log4j.properties in each module and running unit tests, logs are created fine in eclipse.

Websphere ND 6.1.0.17

This is more of a websphere deployment question but it still relates to the log. When i deploy my enterprise application in websphere, if i go to my WAS_ROOT\profiles... \installedApps\ProjectName.ear all i see is my jar files, how can i see the logs i create without looking inside the jars?

I know there is a properties folder at WAS_ROOT\profiles\AppSrv01 level and if i place my log4j.properties in here my log files get created at the AppSrv01 level, is there another way to view my logs at my project directory location.

Maybe it is just log4j.appender.C.File value i have to change.

Thanks,
Shane.
 
Consider Paul's rocket mass heater.
 
subject: log4j in eclipse enterprise application project
 
Similar Threads
Multiple modules in same directory structure
Weblogic 8.1 Deployment using Eclipse OEPE
Using Logging in EJB
logging in websphere
Some Deployment Error. JBoss(4.2). Error code 404 displayed while running Project.