Asp.Net MVC - SecurityException:未找到源,但无法搜索部分或所有事件日志。无法访问的日志:安全

Asp.Net MVC - SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

所以我在 Visual Studio 中使用 AWS 工具包扩展通过 AWS Elastic Beanstalk(附加了一个 AWS RDS 实例)部署我的网站。我的网络应用程序同时使用了 sensenet 服务和 sensenet 网页组件。 sensenet 服务是强制性组件,必须存在才能使用其他sensenet 组件。 sensnet 网页组件为用户提供了一个管理 GUI,这是每当有人访问该站点时都会显示的内容。

我的问题是每次访问我的网站时都会出现此安全异常(通过本地主机 运行 时不会出现此问题)。

Server Error in '/' Application.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.]
   System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate) +441
   System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate) +125
   System.Diagnostics.EventLog.SourceExists(String source) +23
   SenseNet.Diagnostics.SnEventLogger..ctor(String logName, String logSourceName) +71
   SenseNet.Configuration.<>c.<.ctor>b__153_0() in E:\BuildAgent\_work\s\src\Storage\Configuration\Providers.cs:83
   System.Lazy`1.CreateValue() +708
   System.Lazy`1.LazyInitValue() +184
   SenseNet.ContentRepository.RepositoryInstance.InitializeLogger() in E:\BuildAgent\_work\s\src\ContentRepository\RepositoryInstance.cs:350
   SenseNet.ContentRepository.RepositoryInstance.DoStart() in E:\BuildAgent\_work\s\src\ContentRepository\RepositoryInstance.cs:130
   SenseNet.ContentRepository.RepositoryInstance.Start(RepositoryStartSettings settings) in E:\BuildAgent\_work\s\src\ContentRepository\RepositoryInstance.cs:107
   SenseNet.ContentRepository.Repository.Start(RepositoryStartSettings settings) in E:\BuildAgent\_work\s\src\ContentRepository\Repository.cs:55
   SenseNet.Services.SenseNetGlobal.Application_Start(Object sender, EventArgs e, HttpApplication application) in E:\BuildAgent\_work\s\src\Services\SenseNetGlobal.cs:156
   DERContentRepository.MvcApplication.Application_Start(Object sender, EventArgs e, HttpApplication application) in Global.asax.cs:12
   SenseNet.Portal.Global.Application_Start(Object sender, EventArgs e) in E:\BuildAgent\_work\s\src\Services\Global.cs:16

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3163.0

我读过一些类似这样的 Whosebug 帖子

System.Security.SecurityException when writing to Event Log

The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

谈论 运行宁 visual studio 作为管理员(这没有用)和 使用应用程序的名称创建注册表项。最后一种方法我很确定它会在开发中起作用但不确定它在部署时是否会起作用。在部署网站时有什么想法可以解决这个问题吗?

IIS Express 10

ASP.NET MVC v4.6.2

Windows服务器 2016 v1.2.0

系统启动时会尝试初始化记录器组件。在默认安装中,这是一个简单的事件记录器,它尝试将事件写入 Windows 事件日志 - 如果不存在适当的日志,它 尝试即时创建它。在某些环境中,应用程序用户对此没有 (Windows) 权限,这是正常的。

您有多种选择:

  • 手动创建事件日志(请参阅 createeventlog SnAdmin 工具 here
  • 使用不同的记录器将日志条目写入其他地方,而不是事件日志。例如,SnFileSystemEventLogger 将条目写入文件系统。要配置记录器,您可以在 MvcApplication 中使用存储库构建器 API:

```

public class MvcApplication : SenseNet.Portal.SenseNetGlobal
{
    protected override void Application_Start(object sender, EventArgs e, HttpApplication application)
    {
        ...
    }

    protected override void BuildRepository(IRepositoryBuilder repositoryBuilder)
    {
        repositoryBuilder.UseLogger(new SnFileSystemEventLogger());
    }
}