File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Engineering » Testing
Bookmark "test log4j being picked up in webapp" Watch "test log4j being picked up in webapp" New topic
Author

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 log4j.properties 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
Marshal

Joined: May 26, 2003
Posts: 30749
    
156

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: test log4j being picked up in webapp