【问题标题】:log4net permission issue to write to application event log when the user is not in admin group in Windows 2008 R2 and IIS 7当用户不在 Windows 2008 R2 和 IIS 7 的管理员组中时,log4net 写入应用程序事件日志的权限问题
【发布时间】:2011-07-08 19:04:25
【问题描述】:

当用户不在 Windows 2008 R2 和 IIS 7 的管理员组中时,我遇到 ASP.Net 4.0 Web 应用程序写入应用程序事件日志的 log4net 权限问题。我们正在使用 NT 身份验证和模拟。一旦我将用户分配到管理员组,它就可以正常工作。 我尝试了许多权限设置,例如授予 Authenticated Users 对注册表中 Eventlog 的完全权限等,但它们都不起作用。如果有人可以提供帮助,那就太好了。

当我在 Windows 2003 服务器上从 .net 1.1 应用程序记录到事件日志时遇到类似问题时,我按照下面的链接进行了 CustomSD 条目,它起作用了

http://mossipqueen.wordpress.com/2008/08/04/cannot-open-log-for-source-you-may-not-have-write-access/

我得到的错误来自 log4net 内部日志。

log4net:ERROR [EventLogAppender] Unable to write to event log [Application] using source [*******]
System.InvalidOperationException: Cannot open log for source '*******'. You may not have write access. ---> System.ComponentModel.Win32Exception: Access is denied
   --- End of inner exception stack trace ---
   at System.Diagnostics.EventLogInternal.OpenForWrite(String currentMachineName)
   at System.Diagnostics.EventLogInternal.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName)
   at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
   at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
   at log4net.Appender.EventLogAppender.Append(LoggingEvent loggingEvent)

【问题讨论】:

    标签: asp.net iis-7 log4net event-log


    【解决方案1】:

    也许我在这里遗漏了一些东西,但对于该用户来说,这似乎是一个简单的权限问题。默认情况下,他们无权写入应用程序日志文件。我知道你玩弄了这些权限,但我不确定你分配了哪些权限。

    这是一篇 Microsoft 文章,介绍了完全按照您的意愿来克服您所看到的错误:

    http://support.microsoft.com/kb/2028427

    如果你遵循这个,你应该解决你的问题。我希望这会有所帮助。

    【讨论】:

    • 抱歉延迟回复。今天再次检查这个。感谢您的知识库文章。我从命令提示符以管理员身份运行的经过身份验证的用户的最后一个条目尝试了以下操作,它现在似乎可以工作 wevtutil sl application /ca:O:BAG:SYD:(A;;0xf0007;;;SY)(A;;0x7 ;;;BA)(A;;0x7;;;SO)(A;;0x3;;;IU)(A;;0x3;;;‌​‌​SU)(A;;0x3;;;S-1 -5-3)(A;;0x3;;;S-1-5-33)(A;;0x1;;;S-1-5-32-573)(A;;0x3;;;AU)
    • 我确实在事件日志条目的顶部看到了以下文本,如果您知道关闭此功能的方法,请告诉我无法找到来自源 MyAppTest 的事件 ID 0 的描述。引发此事件的组件未安装在本地计算机上,或者安装已损坏。您可以在本地计算机上安装或修复组件。如果事件起源于另一台计算机,则显示信息必须与事件一起保存。活动中包含以下信息:
    • 我创建了一个实用程序 (Windows Form/C#),它将在应用程序事件日志中创建事件源,并将删除顶部不必要的消息,它似乎工作(我试图创建事件源和相关条目直接在注册表中,似乎在 Windows 2008 中由于某种原因无法正常工作)
    猜你喜欢
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-20
    • 2014-11-01
    • 2011-07-29
    • 1970-01-01
    相关资源
    最近更新 更多