You can have as many loggers as you like. It's the appenders that you define in your configuration, not the loggers. But the log4j system only has one central point of configuration, so having more than one configuration file doesn't make sense.
There are two sub projects need logger, each sub project will be compiled to one jar file.
I hope one project's logger class can write to one file, and another project's logger class write to another file. The level and other configuration for the appender are same.
Is it possible to configure the log4j xml configuration file to receive certain logger class?
If you want to be logging to two different files, then you need two different appenders to log to those files. I don't know what you mean by a "logger class" but you can certainly configure a specific logger to use a specific appender.
I don't even know what that means. If I guess what it might mean, I have no idea why you would want to do that anyway. Or are you asking how to configure log4j?
I have two services in one application. In IDE environment, they are two sub projects, and will be compiled to two jars. So I want to save their logs to different files.
The problem is although they are separate projects, they will be deployed to one war. They will work in same JVM.
I have defined their own appender for different log file output in xml configuration file. My question is how can I get the instance of org.apache.log4j.Logger which uses the certain appender for different service?
Originally posted by Padma Lalwani: In log4j.xml, create two appenders e.g. service1 and service2, writing to two different files. Then add package level filter to each appender