|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Very Easy Question, How to write log to SECURTY Event Log? Please helpEvent Log? The following code give me "Very Easy Question, How to write log to SECURTY Event Log? Please help" Error // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.Source = "Security"; // Write an informational entry to the event log. myLog.WriteEntry("Writing warning to event log.", EventLogEntryType.Warning); but as soon as I change "Security" to "Application" , everything works fine // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.Source = "Application"; // Write an informational entry to the event log. myLog.WriteEntry("Writing warning to event log.", EventLogEntryType.Warning); Any ideas? Thanks in advance John John,
What happens when you try and write to the security event log? Do you get an exception or something of that nature? If so, what is it? -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "John" <john***@yahoo.com> wrote in message news:1146501188.315736.13980@v46g2000cwv.googlegroups.com... > Is there any special code I have to write to log event to Security > Event Log? The following code give me "Very Easy Question, How to > write log to SECURTY Event Log? Please help" Error > > // Create an EventLog instance and assign its source. > EventLog myLog = new EventLog(); > myLog.Source = "Security"; > > // Write an informational entry to the event log. > myLog.WriteEntry("Writing warning to event log.", > EventLogEntryType.Warning); > > > but as soon as I change "Security" to "Application" , > everything works fine > > // Create an EventLog instance and assign its source. > EventLog myLog = new EventLog(); > myLog.Source = "Application"; > > // Write an informational entry to the event log. > myLog.WriteEntry("Writing warning to event log.", > EventLogEntryType.Warning); > > > Any ideas? > Thanks in advance > John > if throw exception the following exception:
Cannot open log for source 'Security'. You may not have write access. Nicholas Paldino [.NET/C# MVP] wrote: Show quote > John, > > What happens when you try and write to the security event log? Do you > get an exception or something of that nature? If so, what is it? > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mvp@spam.guard.caspershouse.com > > "John" <john***@yahoo.com> wrote in message > news:1146501188.315736.13980@v46g2000cwv.googlegroups.com... > > Is there any special code I have to write to log event to Security > > Event Log? The following code give me "Very Easy Question, How to > > write log to SECURTY Event Log? Please help" Error > > > > // Create an EventLog instance and assign its source. > > EventLog myLog = new EventLog(); > > myLog.Source = "Security"; > > > > // Write an informational entry to the event log. > > myLog.WriteEntry("Writing warning to event log.", > > EventLogEntryType.Warning); > > > > > > but as soon as I change "Security" to "Application" , > > everything works fine > > > > // Create an EventLog instance and assign its source. > > EventLog myLog = new EventLog(); > > myLog.Source = "Application"; > > > > // Write an informational entry to the event log. > > myLog.WriteEntry("Writing warning to event log.", > > EventLogEntryType.Warning); > > > > > > Any ideas? > > Thanks in advance > > John > > Only administrator can read from the security log, but user programs cannot
write to the security log, this is a privilege of the security subsystem only. Willy. Show quote "John" <john***@yahoo.com> wrote in message news:1146501188.315736.13980@v46g2000cwv.googlegroups.com... | Is there any special code I have to write to log event to Security | Event Log? The following code give me "Very Easy Question, How to | write log to SECURTY Event Log? Please help" Error | | // Create an EventLog instance and assign its source. | EventLog myLog = new EventLog(); | myLog.Source = "Security"; | | // Write an informational entry to the event log. | myLog.WriteEntry("Writing warning to event log.", | EventLogEntryType.Warning); | | | but as soon as I change "Security" to "Application" , | everything works fine | | // Create an EventLog instance and assign its source. | EventLog myLog = new EventLog(); | myLog.Source = "Application"; | | // Write an informational entry to the event log. | myLog.WriteEntry("Writing warning to event log.", | EventLogEntryType.Warning); | | | Any ideas? | Thanks in advance | John | Try this article:
http://msdn.microsoft.com/msdnmag/issues/05/10/Auditing/default.aspx Joe K. Show quote "John" <john***@yahoo.com> wrote in message news:1146501188.315736.13980@v46g2000cwv.googlegroups.com... > Is there any special code I have to write to log event to Security > Event Log? The following code give me "Very Easy Question, How to > write log to SECURTY Event Log? Please help" Error > > // Create an EventLog instance and assign its source. > EventLog myLog = new EventLog(); > myLog.Source = "Security"; > > // Write an informational entry to the event log. > myLog.WriteEntry("Writing warning to event log.", > EventLogEntryType.Warning); > > > but as soon as I change "Security" to "Application" , > everything works fine > > // Create an EventLog instance and assign its source. > EventLog myLog = new EventLog(); > myLog.Source = "Application"; > > // Write an informational entry to the event log. > myLog.WriteEntry("Writing warning to event log.", > EventLogEntryType.Warning); > > > Any ideas? > Thanks in advance > John > True. As I said in my previous answer, you can't write to the Security log
from user code. Even the code as presented in the article needs elevated privileges to register a provider and the program needs to run with 'SeAuditingPrivileges' enabled, something you don't want to do from regular user applications, only very security conscious services need this. Why do you want to write to the security log anyway, applications and services should write to the 'Application' log or a private log. Willy. Show quote "John" <john***@yahoo.com> wrote in message news:1146509954.795586.193810@j73g2000cwa.googlegroups.com... | Looks like it only works for WIndows 2003, not Windox XP | Try this: http://support.microsoft.com/kb/323076
Show quote "Willy Denoyette [MVP]" wrote: > True. As I said in my previous answer, you can't write to the Security log > from user code. Even the code as presented in the article needs elevated > privileges to register a provider and the program needs to run with > 'SeAuditingPrivileges' enabled, something you don't want to do from regular > user applications, only very security conscious services need this. > Why do you want to write to the security log anyway, applications and > services should write to the 'Application' log or a private log. > > Willy. > > > "John" <john***@yahoo.com> wrote in message > news:1146509954.795586.193810@j73g2000cwa.googlegroups.com... > | Looks like it only works for WIndows 2003, not Windox XP > | > > > "Kevin" <Ke***@discussions.microsoft.com> wrote in message Why? This does explain how to set 'Application' and 'System' eventlog news:38CFD19E-E364-41D0-BF10-DA7B2503BF71@microsoft.com... | Try this: http://support.microsoft.com/kb/323076 | | security, it doesn't say you can write to the 'Security' log because you can't. Willy. |
|||||||||||||||||||||||