This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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

Win a copy of Building Microservices this week in the Design forum!
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

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

These are all module dependencies for my root project folder.

So if i have logging in each module where does the 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?

Peter Johnson

Joined: May 14, 2008
Posts: 5852

The 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 it will work. I will test myself to see.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17039

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).

An IDE is no substitute for an Intelligent Developer.
Shane Lee
Ranch Hand

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

Websphere ND

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 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.

Have you checked out Aspose?
subject: log4j in eclipse enterprise application project
It's not a secret anymore!