By default only one log file is created in multi-site scenario also.

We have come across requirement to generate log file as per site i.e. each site have its own log file. So it'll easy to debug and trace any issue.

www.site1.com log.site1.20190702.152425.txt
www.site2.com log.site2.20190702.152425.txt

Please illuminate on custom implementation to achieve this.

  • Do you have a permanent list if sites? Do you need to create a special logger for each of them or do you need a logger will also be created when you create a new site? Commented Aug 6, 2019 at 12:48
  • I have permanent list of sites. I want to generate per site log file to easily investigate site specific issues. Commented Aug 6, 2019 at 15:54

1 Answer 1


First, start by adding multiple appender to your app.config:

    <appender name="site1" type="log4net.Appender.RollingFileAppender">
        <file value="site1.txt" />
        <appendToFile value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %message%newline" />
    <appender name="site2" type="log4net.Appender.FileAppender">
        <file value="site2.txt" />
        <appendToFile value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %message%newline" />
    <level value="ALL" />
    <appender-ref ref="site1" />
  <logger additivity="false" name="site2">
    <level value="DEBUG"/>
    <appender-ref ref="site2" />

then in code you can call them by:

ILog site1 = LogManager.GetLogger("site1");
ILog site2 = LogManager.GetLogger("site2");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.