当用户不在 Windows 2008 R2 和 IIS 7 中的管理员组中时,log4net 权限问题写入应用程序事件日志

发布于 2024-11-19 07:10:03 字数 1492 浏览 5 评论 0 原文

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

当我在 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)

I am having log4net permission issue from ASP.Net 4.0 web application to write to application event log, when the user is not in administrator group in Windows 2008 R2 and IIS 7. We are using NT authentication and impersonation. Once I assign the user to admin group it works fine.
I tried with many permission settings like giving Authenticated Users full permission to Eventlog in registry etc. and none of them work. If any one can help that will be great.

When I had a similar issue with logging to eventlog from a .net 1.1 app on Windows 2003 server I did CustomSD entry as below link and it worked

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

The error I get is below from log4net internal log.

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十秒萌定你 2024-11-26 07:10:03

也许我在这里遗漏了一些东西,但它看起来像是该用户的一个简单的权限问题。默认情况下,他们无权写入应用程序日志文件。我知道您使用了权限,但我不确定您分配了哪些权限。

以下是一篇 Microsoft 文章,介绍如何按照您的意愿执行操作来克服所看到的错误:

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

如果您遵循此操作,则应该可以解决您的问题。我希望这有帮助。

Maybe I'm missing something here but it looks like a simple permissions issue for that user. By default they don't have access to write to the application log file. I know you played around with the permissions but I'm not sure exactly what permissions you assigned.

Here is a Microsoft article on doing exactly what you want to do to overcome the error you are seeing:

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

If you follow this, you should solve your issue. I hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文