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

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 写入应用程序事件日志的权限问题)

本文介绍了当用户不在 Windows 2008 R2 和 IIS 7 的管理员组中时,log4net 写入应用程序事件日志的权限问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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/

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

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)

推荐答案

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

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.

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

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.

这篇关于当用户不在 Windows 2008 R2 和 IIS 7 的管理员组中时,log4net 写入应用程序事件日志的权限问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

基础教程推荐