Log4net
  1. Log4net
  2. LOG4NET-65

Unhandled SecurityException exception for FileIOPermission while loading configuration file

    Details

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

      Description

      If the calling application does not have the PathDiscovery FileIOPermission a SecurityException is generated from the XmlConfiguratorAttribute.Configure method. This is called from the first LoggerManager.GetLogger in a calling assembly.

      The exception should be caught as we may potentially be injecting this exception into user code's class initialisation phase which the user would find unexpected.

      An example stack trace for the exception is:

      [SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
      System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
      System.Security.CodeAccessPermission.Demand() +59
      System.AppDomainSetup.VerifyDir(String dir, Boolean normalize) +110
      System.AppDomain.get_BaseDirectory() +61
      log4net.Util.SystemInfo.get_ApplicationBaseDirectory() +31
      log4net.Config.XmlConfiguratorAttribute.Configure(Assembly sourceAssembly, ILoggerRepository targetRepository) +30
      log4net.Core.DefaultRepositorySelector.ConfigureRepository(Assembly assembly, ILoggerRepository repository) +314
      log4net.Core.DefaultRepositorySelector.CreateRepository(Assembly repositoryAssembly, Type repositoryType, String repositoryName, Boolean readAssemblyAttributes) +532
      log4net.Core.DefaultRepositorySelector.CreateRepository(Assembly repositoryAssembly, Type repositoryType) +42
      log4net.Core.DefaultRepositorySelector.GetRepository(Assembly repositoryAssembly) +80
      log4net.Core.LoggerManager.GetLogger(Assembly repositoryAssembly, String name) +132
      log4net.LogManager.GetLogger(Assembly repositoryAssembly, String name) +30
      log4net.LogManager.GetLogger(String name) +34

        Activity

        Hide
        Nicko Cadell added a comment -

        Checked in a code fix to this issue that adds additional try/catch blocks to check for the PathDiscovery permissions exception and to log more details of the error condition.

        Show
        Nicko Cadell added a comment - Checked in a code fix to this issue that adds additional try/catch blocks to check for the PathDiscovery permissions exception and to log more details of the error condition.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development