I could do this using PropertyFilter. I defined the following appender in config file:
<appender name="UiFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Log1.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
<filter type="log4net.Filter.PropertyFilter">
<Key value="channel"/>
<StringToMatch value="ui" />
<AcceptOnMatch value="true" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
</appender>
<appender name="WsFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Log1.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
<filter type="log4net.Filter.PropertyFilter">
<Key value="channel"/>
<StringToMatch value="ws" />
<AcceptOnMatch value="true" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
</appender>
The important part of the above appender is tags. When the user is using UI I set "channel" property to "ui" like following code:
log4net.GlobalContext.Properties["channel"] = "ui";
and when user uses web services I use the following code:
log4net.GlobalContext.Properties["channel"] = "ws";
I need to set "channel" property on highest level of entry when request is initiated.