Log4Net Different files in the same assembly


Instead
private static readonly log4net.ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
use 
private static readonly log4net.ILog Logger = log4net.LogManager.GetLogger("ShipmentLogger");

In the
Remember to set additivity="false"   since this logger appender inheriting from parents

<log4net>
    <root>
      <level value="ALL" />
      <appender-ref ref="FileAppenderTxt" />
    </root>
    <logger name="ShipmentLogger" additivity="false">
        <level value="ALL" />
        <appender-ref ref="ShipFileAppenderTxt" />
    </logger>
    <appender name="FileAppenderTxt" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="E:\\Skynet\\ItemDataService\\AppLogs\" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value="'Service-Log-'yyyyMMdd'.txt'" />
      <staticLogFileName value="false" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
      <param name="Encoding" value="utf-8" />
    </appender>
    <appender name="ShipFileAppenderTxt" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="E:\\Skynet\\ItemDataService\\AppLogs\" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value="'ShipService-Log-'yyyyMMdd'.txt'" />
      <staticLogFileName value="false" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
      <param name="Encoding" value="utf-8" />
    </appender>
  </log4net>
  

Comments

Popular posts from this blog

ටෙස්ලා

Setup Test automation with Selenium and Ruby