File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes log4j on 2 jars on the same classloader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "log4j on 2 jars on the same classloader" Watch "log4j on 2 jars on the same classloader" New topic

log4j on 2 jars on the same classloader

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Hi folks
We have 2 jars that are loaded on the same classloader,
I would like to properly initialize log4j (1.2.15) so it will write to different log location for each jar.

I renamed each log4j property file to the plugin name, but log is created with single line only
Once I use just one jar - The log is working ok,
What am I missing here?

Thank you!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15047

Are the classes in the two JAR files in different packages? Then you can just configure your loggers and appenders in the Log4J configuration file differently for the classes in the two different packages. No need to do complicated tricks.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Devarsh Shah

Joined: Mar 02, 2012
Posts: 6

Can you please explain why two jars are required??
I agree. Here's the link:
subject: log4j on 2 jars on the same classloader
jQuery in Action, 3rd edition