views:

80

answers:

1

If I have log4net configured as below

 <root>
  <level value="INFO" />
  <appender-ref ref="RollingFileAppender" />
 </root>

 <logger name="MyNamespace.MyClass">
  <level value="INFO" />
  <appender-ref ref="AdoNetAppender" />
 </logger>

I would like the output from the named class to end up only in the sql database (via the adoNetAppender) and not in both the sql database and the log file (via the rollingfileappender).

Is there a way of achieving that?

+2  A: 

You can set the additivity attribute on logger to false. From the documentation:

Set this attribute to false to prevent this logger from inheriting the appenders defined on parent loggers.

<logger name="MyNamespace.MyClass" additivity="false">
    <level value="INFO" />
    <appender-ref ref="AdoNetAppender" />
</logger>
Peter Lillevold
Yes, that works perfectly.Thank you very much.
sgmoore
@sgmoore - you're welcome :)
Peter Lillevold