SRAMPI
SRAMPI

Reputation: 373

log4net permission issue to write to application event log when the user is not in admin group in Windows 2008 R2 and IIS 7

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)

Upvotes: 1

Views: 9108

Answers (1)

IAmTimCorey
IAmTimCorey

Reputation: 16757

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.

Upvotes: 2

Related Questions