Not able to write to Security Log

Topics: Logging Application Block
Aug 26, 2009 at 7:03 AM


am not able to write log into Security Log using Event TraceListener.

Getting the following Error:

Exception Type: System.InvalidOperationException
Message: Cannot open log for source 'Enterprise Library Logging1'. You may not have write access.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OpenForWrite(System.String)
HelpLink: NULL
Source: System

StackTrace Information Details:
   at System.Diagnostics.EventLog.OpenForWrite(String currentMachineName)
   at System.Diagnostics.EventLog.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName)
   at System.Diagnostics.EventLog.WriteEvent(EventInstance instance, Byte[] data, Object[] values)
   at System.Diagnostics.EventLog.WriteEvent(EventInstance instance, Object[] values)
   at System.Diagnostics.EventLogTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType severity, Int32 id, Object data)
   at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedTraceListenerWrapperBase.TraceData(TraceEventCache eventCache, String source, TraceEventType severity, Int32 id, Object data)
   at Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter)
   at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.ProcessLog(LogEntry log)


can u plz tell us how to resolve this?



Aug 26, 2009 at 9:58 AM


Do you have repro steps for this? Do you just change the Log property of the Event log trace listener? Can you provide the exact steps?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Aug 26, 2009 at 10:19 AM

I have added  Event TraceListener :

<add source="Credential Logging" formatter="TextFormatter" log="Security"
        machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="CredentialEvtViewerTraceListener" />

added that in categiries:

<add name="CredentialEvtViewerTraceListener" />

In Application and other test Logs (Created Logs) its working fine..

But in Security Log its not working.



Aug 26, 2009 at 1:10 PM

How about in the settings of your security event log? did you register another source for the Security log?