tags:

views:

18

answers:

0

Hi. I have the following situation. There are 2 classes: ClassA, ClassB. I want them to log in different files ClassA.log, ClassB.log. For this purpose I am using the RollingFileAppender. How can I write this in a shorter way than the following:

<appender name="RollingFileAppenderA" type="log4net.Appender.RollingFileAppender">
    <file value="ClassA.log" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="100KB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
</appender>

<appender name="RollingFileAppenderB" type="log4net.Appender.RollingFileAppender">
  <file value="ClassB.log" />
  <appendToFile value="true" />
  <rollingStyle value="Size" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="100KB" />
  <staticLogFileName value="true" />
  <layout type="log4net.Layout.PatternLayout">
  <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
  </layout>
</appender>

As you can see, the only thing the appenders differ is the filename where they are writing logs. So, is there a way to define a single RollingFileAppender for the given problem?