Hi, I have a requirement where in I want to use log4j logging for a single component(read java class) in my application, but the problem is that a log4j configuration is already in place for other third party components in the same classloader scope. I tried configuring the log4j properties programmatically. It logs fine for the target log file, which I had set for the my appender, for sometime, but later on the logs get printed in the file specified by the root logger appender(which is specified in the core log4j.properties). How can I circumvent the situation? Any suggestions ?
I forgot mentioning that once the logs get printed in the root appender file, they no longer get printed to the file appender which I have set.
I'm no expert on configuring it in Java code, but it looks like that should work yes. Can you not actually access the properties file itself?
Joined: Apr 05, 2009
The main configuration file is for a different module altogether. It's just that their jar files are exposed to our application because we refer them. Since there is a shared class loader for all the jars, I can not configure my separate log4j configuration. In case I define a root logger in my own config file, it may overwrite theirs and that won't be a welcome situation.
So I was just trying to devise a way and hence I posted this query. It seems now that I'll have to append my configuration in their properties file only.