I need to log debugging messages from the same class into different files.
What I mean is that from the same class I need a specific debug statement to go to fileA while another specific debug statement to go to fileB.
In case it is not clear, what I am trying to do is to log network messages to a completely separate file than other loggin messages that this class outputs.
If I do
<logger name="com.test.modules" additivity="false" >
<priority value="debug"/>
<appender-ref ref="netWorkCommunication"/>
<appender-ref ref="generalDebug"/>
</logger>
Then the logging from my class will go to both files (since it is from the same package).
How can I configure log4j so that I can select which logging statement from classes under com.test.modules go to which file appender?
Use a separate Logger for each file:
and define the appender for each Logger as usual.