My web app supports multiple instances, e.g. instance 1, 2, each of which logs data into its own file via log4net. That is I want to log data into different files based on instance id programmatically. The file path should be:
D:\Projects\Log\1\Reporting.log for instance 1
D:\Projects\Log\2\Reporting.log for instance 2
My web app support 3 instances, do I need to have 3 loggers in C#, which ONLY differ by its log file path, as shown above?
Below is Log4Net.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="ExceptionLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value=????How to specify this????? />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="-yyyy-MM-dd.lo\g" />
<param name="StaticLogFileName" value="false" />
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="------------------------------------------ " />
<param name="Footer" value="------------------------------------------ " />
<conversionPattern value="%d|[%t]|%-5p|%c|%m%n"/>
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<level value="ERROR" />
<appender-ref ref="ExceptionLogFileAppender" />
</root>
</log4net>
</configuration>
UPDATE
The instance id must be 1,2, etc.
The instance id would have more than 100 in the future.
Any idea would be much appreciated!