473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
8 6593
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
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
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
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
Looks like it only works for WIndows 2003, not Windox XP

May 1 '06 #6
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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex | last post by:
Hello I am interested learn more about .NET but am uncertain of exactly what niche it fills in the world of programming. (The more I read the more I am confused). What I am looking for is the...
4
by: Steven | last post by:
I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions. I have created a category named Exceptions with the following: <category...
10
by: Jason Curl | last post by:
Greetings, I have an array of 32 values. This makes it extremely fast to access elements in this array based on an index provided by a separate enum. This array is defined of type "unsigned long...
3
by: Jesper Denmark | last post by:
Within the following construction switch (expression) { int i; i = GetArgs() //return 2 case constant-expression:
6
by: No_Excuses | last post by:
All, I am interested in reading the text of a web page and parsing it. After searching on this newgroup I decided to use the following: ******************************* START OF CODE...
3
by: Brent | last post by:
Hi everyone. I am moving from VB.Net to C#. C# is pretty easy but i do have one thing i don't like that im probably doing it the hard way and want to see if there is an easy way to do it. When you...
6
by: msnews.microsoft.com | last post by:
Hello All, I am very new to ASP.NET and I have a basic question. Can somebody please explain? I have an .aspx Web Page with a textbox control. When the Page initially loads I am calling a...
1
by: Kiran | last post by:
Hello All, I created a grid, where I register events every time the user changes an existing value inside the grid control. Right now, I am using the event: EVT_GRID_CELL_CHANGE. However, I...
1
by: halekio | last post by:
Hi all, Please bear with me as I've only started programming in C# 2 weeks ago and this is my first contact with OOP. I ran into a situation where I needed to catch an event in an object that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.