8

i want to log messages from multiple classes. the problem is that currently i can log all messages into single file.i want to do this class A should log its messages into ALog.txt and class B should log its messages into BLog.txt

please tell me the sample config file for these settings

BenMorel
  • 31,815
  • 47
  • 169
  • 296
Mohsan
  • 2,475
  • 6
  • 46
  • 62

1 Answers1

16

In addition to the root logger, you can configure individual loggers with their own appenders. Assuming you are calling your loggers ClassA and ClassB you can do:

<root>
     <appender-ref ref="CommonAppender" />
</root>
<logger name="ClassA">
     <appender-ref ref="AppenderA" />
</logger>
<logger name="ClassB">
     <appender-ref ref="AppenderB" />
</logger>

This is further described here.

Peter Lillevold
  • 33,065
  • 7
  • 95
  • 129