I have a web application and would like to log to different files depending on which web service gets called.
So WS1 will log to WS1_log.txt for example, while WS2 will log to WS2_log.txt.
Is this possible?
I have a web application and would like to log to different files depending on which web service gets called.
So WS1 will log to WS1_log.txt for example, while WS2 will log to WS2_log.txt.
Is this possible?
How about putting the log4net config in a web.config most local to the web service.
I think you may find your answer here Change log file
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
<file type="log4net.Util.PatternString"
value="%envFolderPath{CommonApplicationData}\\test.txt" />
...
</appender>
Yes you can do that. Create two (rolling) file appenders in your configuration and then configure your loggers like this:
<appender name="FileAppenderWebservice1" type="log4net.Appender.RollingFileAppender">
<file value="c:\logs\webservice1.txt" />
...
</appender>
<appender name="FileAppenderWebservice2" type="log4net.Appender.RollingFileAppender">
<file value="c:\logs\webservice2.txt" />
...
</appender>
<root>
<level value="ALL" />
</root>
<logger name="YourNameSpace.Webservice1Class">
<appender-ref ref="FileAppenderWebservice1" />
</logger>
<logger name="YourNameSpace.Webservice2Class">
<appender-ref ref="FileAppenderWebservice2" />
</logger>
This requires that you create a logger per webservice like this:
ILog logger = LogManager.GetLogger(typeof(WebserviceClass));