Log4net
  1. Log4net
  2. LOG4NET-36

System.Diagnostics.Trace may throw exception if AppDomain does not have config file

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.9
    • Fix Version/s: 1.2.10
    • Component/s: Core
    • Labels:
      None

      Description

      System.Diagnostics.Trace may throw exception if AppDomain does not have config file.

      If the AppDomain has been created programmatically it is possible that it does not have a config file set. It has been reported that an exception can be generated on certain platforms in this situation.

      The exception is:

      System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
      System.TypeInitializationException: The type initializer for "D2L.Mail.MailService" threw an exception. --->
      System.TypeInitializationException: The type initializer for "log4net.Core.LoggerManager" threw an exception. --->
      System.TypeInitializationException: The type initializer for "log4net.Util.LogLog" threw an exception. --->
      System.NullReferenceException: Object reference not set to an instance of an object.

      at System.Configuration.ConfigurationSettings.GetConfig(String sectionName)
      at System.Diagnostics.DiagnosticsConfiguration.GetConfigTable()
      at System.Diagnostics.DiagnosticsConfiguration.Initialize()
      at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
      at System.Diagnostics.TraceInternal.InitializeSettings()
      at System.Diagnostics.TraceInternal.get_Listeners()
      at System.Diagnostics.TraceInternal.WriteLine(String message)
      at System.Diagnostics.Trace.WriteLine(String message)
      at log4net.Util.LogLog.Error(String message, Exception exception)
      at log4net.Util.LogLog..cctor()

      — End of inner exception stack trace —

      at log4net.Util.LogLog.Debug(String message)
      at log4net.Core.LoggerManager..cctor()

      — End of inner exception stack trace —

      at log4net.Core.LoggerManager.GetLogger(Assembly
      repositoryAssembly, String name)
      at log4net.LogManager.GetLogger(Type type)
      at D2L.Mail.MailService..cctor()

      — End of inner exception stack trace —

      — End of inner exception stack trace —

        Activity

        Nicko Cadell created issue -
        Hide
        Nicko Cadell added a comment -

        Added try catch blocks to the LogLog internal calls. If an exception occurs in the LogLog calls the exception is caught and discarded. The LogLog class is the last line of defence and the caller does not expect it to leak exceptions, and it does not have an alternative even if it did receive the exception.

        Show
        Nicko Cadell added a comment - Added try catch blocks to the LogLog internal calls. If an exception occurs in the LogLog calls the exception is caught and discarded. The LogLog class is the last line of defence and the caller does not expect it to leak exceptions, and it does not have an alternative even if it did receive the exception.
        Nicko Cadell made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]

          People

          • Assignee:
            Nicko Cadell
            Reporter:
            Nicko Cadell
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development