Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-594

repository.GetAppenders() returns log4net.Appender.IAppender[0]

    Details

    • Type: Bug
    • Status: Reopened
    • Priority: Blocker
    • Resolution: Unresolved
    • Affects Version/s: 2.0.8
    • Fix Version/s: 2.0.8
    • Component/s: Appenders
    • Labels:
    • Environment:
      Windows PowerShell Console

      Description

      Hi,

      We are migrating our code base into .Net standard to support both Windows PowerShell console and PowerShell core. We are using log4net 2.0.8 as third party reference with log4Net.config file. There is no build issue with this. But, we have observed "repository.GetAppenders()" returns log4net.Appender.IAppender[0] in Windows PowerShell Console whereas the same is working as expected in PowerShell Core Console. In Windows PowerShell console, It looks like it is not reading the appenders confoguration from log4net.config.

      Code:

      log4net.Repository.ILoggerRepository repository = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Logger.Repository;

      var appenders = repository.GetAppenders();

      Here is log4net.config:

      <configuration>
      <configSections>
      <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
      </configSections>
      <log4net>
      <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="FileLog.txt"/>
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <appendToFile value="true"/>
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] [%logger] %level - %message%newline%exception"/>
      </layout>
      </appender>
      <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="%date.log"/>
      <PreserveLogFileNameExtension value="true" />
      <appendToFile value="true"/>
      <rollingStyle value="Size"/>
      <maximumFileSize value="10MB"/>
      <maxSizeRollBackups value="5"/>
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %stacktrace %level - %message%newline%exception"/>
      </layout>
      </appender>
      <root>
      <level value="DEBUG"/>
      <appender-ref ref="RollingFileAppender"/>
      </root>
      </log4net>
      <startup>
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>
      </configuration>

       

      Please let us confirm is it a bug in log4net or something we need to correct from our end.

      Thank you

       

      Regards,

      Rajesh Balakrishnan

       

        Attachments

        1. Log4Net.config
          2 kB
          Rajesh Balakrishnan

          Activity

            People

            • Assignee:
              nachbarslumpi Dominik Psenner
              Reporter:
              Rajesh_Bala Rajesh Balakrishnan
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: