Different log4j configurations within the same application context
Hi,
We have a Spring application using log4j which is configured on startup within Tomcat:
Code:
-Dlog4j.configuration=file:%CATALINA_BASE%/conf/log4j.xml
Currently the application logs to one log file, e.g. system.log.
We have now developed a new component that runs in the same context but is logging to a different log file from the rest of the application e.g. subsystem.log. This is fine for the new code we have developed as we have configured a new logger/appender for subsystem.log in the log4j.xml and reference this in the logging code of the new component.
However the problem is with our common libraries which will always log to the default system.log through:
Code:
Logger.getLogger(this.getClass());
This means we currently have our new component's logging going to 2 separate logs which is not ideal. Ideally where we utilize these common libraries within our new component we would like logging to subsystem.log and where used elsewhere in the system logging would be to system.log. This makes me think we need two log4j configurations, one being specifically for the new component. I'm not sure if it is possible to configure this in Spring. The main problem is that I don't want to override the default logging config anywhere else but in the new component. May be I'm being a tad too optimistic thinking I can do it all in config :)
If anyone has any ideas please let me know! It'd be much appreciated