By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

Very Easy Question, How to write log to SECURTY Event Log? Please help

P: n/a
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

May 1 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com

"John" <jo*****@yahoo.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.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

May 1 '06 #2

P: n/a
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.

"John" <jo*****@yahoo.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.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
|
May 1 '06 #3

P: n/a
Try this article:

http://msdn.microsoft.com/msdnmag/is...g/default.aspx

Joe K.

"John" <jo*****@yahoo.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.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

May 1 '06 #4

P: n/a
if throw exception the following exception:

Cannot open log for source 'Security'. You may not have write access.
Nicholas Paldino [.NET/C# MVP] wrote:
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]
- mv*@spam.guard.caspershouse.com

"John" <jo*****@yahoo.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.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


May 1 '06 #5

P: n/a
Looks like it only works for WIndows 2003, not Windox XP

May 1 '06 #6

P: n/a
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" <jo*****@yahoo.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
| Looks like it only works for WIndows 2003, not Windox XP
|
May 1 '06 #7

P: n/a
Try this: http://support.microsoft.com/kb/323076
"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" <jo*****@yahoo.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
| Looks like it only works for WIndows 2003, not Windox XP
|

May 25 '06 #8

P: n/a

"Kevin" <Ke***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
| Try this: http://support.microsoft.com/kb/323076
|
|

Why? This does explain how to set 'Application' and 'System' eventlog
security, it doesn't say you can write to the 'Security' log because you
can't.

Willy.
May 25 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.