This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Testing and the fly likes test log4j being picked up in webapp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "test log4j being picked up in webapp" Watch "test log4j being picked up in webapp" New topic

test log4j being picked up in webapp

Brian Mulholland
Ranch Hand

Joined: Mar 12, 2009
Posts: 61
I have a webapp and a dependent lib project. The lib project and webapp both have test folders in addition to source folders where I am putting my unit tests. The tests have their own loaded from a propertyconfigurator so that we can figure out what isn't working. The problem is that when I run the actual webapp, I am picking up the log4j's from the test folders. This causes multiple appenders to be defined and double and triple logging.

I am in RAD/Eclipse, and we added the test folder as a source folder (which is probably the root of the problem) but if i do not, then when I try to run the Junit test via the right-click run as... menu, it doesn't find the classes as junit classes.

So I think I am setting my test folders up incorrectly. What is the correct way? Or if this is not wrong, how to I control my log4j problem?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33134

You could put the test files in a different project. That way the unit tests (also in that separate project) see it, but the web app does not.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: test log4j being picked up in webapp
It's not a secret anymore!