I successfully cordoned off my own entry in my own common and error log files.
I added NHibernate to the mix because I would like to write the SQL commands that it generates to help debug, but in my own file.
With the current configuration, which I have below, the NH output ends in my shared log file (CommunicationsAppender), as well as in its own file (it is duplicated). How to save exit from CommunicationsAppender?
<log4net> <appender name="NHibernateAppender" type="log4net.Appender.RollingFileAppender"> <file value="c:\logs\NHibernate.log"/> <appendToFile value="true"/> <maximumFileSize value="1000KB"/> <maxSizeRollBackups value="10"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date %logger %level - %message%newline"/> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="DEBUG" /> <levelMax value="FATAL" /> </filter> <filter type="log4net.Filter.LoggerMatchFilter"> <loggerToMatch value="NHibernate.SQL" /> <acceptOnMatch value="true" /> </filter> <filter type="log4net.Filter.DenyAllFilter" /> </appender> <appender name="CommunicationsAppender" type="log4net.Appender.RollingFileAppender"> <file value="C:\Logs\Communications Service.log"/> <appendToFile value="true"/> <maximumFileSize value="10000KB"/> <maxSizeRollBackups value="10"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date %logger - %message%newline"/> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="DEBUG" /> <levelMax value="WARN" /> </filter> <filter type="log4net.Filter.LoggerMatchFilter"> <loggerToMatch value="CommunicationsLogger" /> <acceptOnMatch value="true" /> </filter> <filter type="log4net.Filter.DenyAllFilter" /> </appender> <appender name="CommunicationsErrorAppender" type="log4net.Appender.RollingFileAppender"> <file value="C:\Logs\Communications Service Errors.log"/> <appendToFile value="true"/> <maximumFileSize value="10000KB"/> <maxSizeRollBackups value="10"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date %logger - %message%newline"/> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="ERROR" /> <levelMax value="FATAL" /> </filter> <filter type="log4net.Filter.LoggerMatchFilter"> <loggerToMatch value="CommunicationsLogger" /> <acceptOnMatch value="true" /> </filter> </appender> <root> <priority value="ALL"/> <appender-ref ref="CommunicationsAppender" /> <appender-ref ref="CommunicationsErrorAppender" /> <appender-ref ref="NHibernateAppender" /> </root> <logger name="NHibernate.SQL"> <level value="DEBUG"/> <appender-ref ref="NHibernateAppender"/> </logger> <logger name="NHibernate"> <level value="OFF" /> </logger> </log4net>
source share