473,750 Members | 2,470 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating EventLog code, is this code correct?

hi

..Net 2.0

I've created the code below and think I've executed it. After I thought I've
executed it I checked in EventLog on the computer (win2k3) and no entry was
added. This could mean 2 things:
- There are some logical errors in my code
- The code wasn't actually executed

string Log = "MIIS_AH";
if ((!(EventLog.So urceExists(Log) )))
{
EventLog.Create EventSource(Log , Log);
}
EventLog logEntry = new EventLog();
logEntry.Source = Log;
logEntry.WriteE ntry("HELLOWORL D");

This code is part of a method with more code inside it. Below I've posted
more of that method just in case you need to see it (MIIS 2003, Provisioning
code). I have some problems with this code, no Connector Space objects are
created (not important what that is), so I added the EventLog code you see
above to my code for the purpose of debugging my code (I wanted to see if my
code actually was executed). As I've heard that I cannot use breakpoints in
the code here. Cannot as this code will be compiled to a .dll which MIIS
(microosft integrated indentry server) will execute. As far as I know it
won't execute debug code. But would be great if I'm wrong about it, as then
I've learned something new ;)

you see any reason why the eventlog code wasn't executed?

CSEntry csentry;
ConnectedMA connectedMA = mventry.Connect edMAs["Bil 2"];
if (connectedMA.Co nnectors.Count == 0)
{
csentry = connectedMA.Con nectors.StartNe wConnector("Bil ");
csentry.DN = connectedMA.Cre ateDN("id");
csentry["Bileier"].Values.Add(mve ntry["Bileier"].Value);
csentry["Bilmerke"].Values.Add(mve ntry["Bilmerke"].Value);
csentry.CommitN ewConnector();
string Log = "MIIS_AH";
if ((!(EventLog.So urceExists(Log) )))
{
EventLog.Create EventSource(Log , Log);
}

EventLog logEntry = new EventLog();
logEntry.Source = Log;
logEntry.WriteE ntry("HELLOWORL D");
}
Jul 15 '08 #1
1 2043
On Jul 15, 5:12*am, "Jeff" <it_consulta... @hotmail.com.NO SPAMwrote:
hi

.Net 2.0

I've created the code below and think I've executed it. After I thought I've
executed it I checked in EventLog on the computer (win2k3) and no entry was
added. This could mean 2 things:
- There are some logical errors in my code
- The code wasn't actually executed

string Log = "MIIS_AH";
if ((!(EventLog.So urceExists(Log) )))
{
EventLog.Create EventSource(Log , Log);}

EventLog logEntry = new EventLog();
logEntry.Source = Log;
logEntry.WriteE ntry("HELLOWORL D");
from seeing it it seems ok, did you see the examples in msdn lib?

Just a dumb question, did you do a refresh in the event log?
do you at least see the new log you are creating?

This code is part of a method with more code inside it. Below I've posted
more of that method just in case you need to see it (MIIS 2003, Provisioning
code). I have some problems with this code, no Connector Space objects are
created (not important what that is), so I added the EventLog code you see
above to my code for the purpose of debugging my code (I wanted to see ifmy
code actually was executed). As I've heard that I cannot use breakpoints in
the code here. Cannot as this code will be compiled to a .dll which MIIS
(microosft integrated indentry server) will execute. As far as I know it
won't execute debug code. But would be great if I'm wrong about it, as then
I've learned something new ;)

you see any reason why the eventlog code wasn't executed?
Maybe you get an exception before the code is executed.
Why don't you first use a file log. and handle all the unhandle
exceptions event
Jul 15 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1730
by: Kimmo Laine | last post by:
Hello, is it possible, when creating new Event log (C#), to specify the log size or other related options. if( !EventLog.SourceExists( sourceName ) ) { EventLog.CreateEventSource( sourceName, logName ); } m_Log = new EventLog();
1
1161
by: Robin | last post by:
On a Windows 2003 server how do you create a new event log that can be written to from an Asp.Net page?
1
1142
by: UJ | last post by:
I am trying to have a service write out to a custom log in the event log. I'm using the following code: Dim lsEventSource As String = "test1234" Dim lsEventLog As String = "CustomLog" If (Not EventLog.SourceExists(lsEventSource)) Then EventLog.DeleteEventSource(lsEventSource) EventLog.CreateEventSource(lsEventSource, lsEventLog)
3
1397
by: clsmith66 | last post by:
I hope this is just something stupid I'm missing and someone can easily point out my error. I'm trying to do a few turorials on windows services, and the couple I found so far just create an event log and write an entry on start and stop. I build the projects and install them fine, but when I run the service it starts and stops instantly. The service is not creating the custom event log I wanted it to but instead adds an error message in...
1
15986
by: martin | last post by:
Hi, I'm having some problems with the System.Diagnostics.EventLog class in .NET 2.0 I need to recreate an event message source inside a new log but the messages keeps ending up in the old log?! I have simplified my code into this tiny snippet: EventLog.CreateEventSource("mySrc", "myLog1");
3
4837
by: Ben | last post by:
I am trying to write an eventlog monitor. I am using the sample code provided by VB2005 SDK as the bases for my application. I need to monitor all three logs (application, system, and security). How can I monitor all three logs at once? Thanks,
0
1816
by: rene | last post by:
I'm trying to use costome categories in my eventlog for a program I'm writing. But I have some problems with it, I cant get it to work. Checklist for how I did this. 1. Created a resourceful.mc content is like this. MessageId=0x1 Severity=Success SymbolicName=INSTALL_CATEGORY
3
1553
by: Hayden Kirk | last post by:
Hi, I'm having a bit of trouble. I want to create a number of controls on the fly. They are all the same control type. How is the best way to do this? I have a name I can assign to them so I know how to reference them, but I don't know how to create them. Thanks Hayden
2
2853
by: =?Utf-8?B?Sm9l?= | last post by:
I am trying to write to the EventLog from a WindowsService that I have written, however when I check to see if the Event Log exists (which it does) it fails. Here's the code. if (EventLog.SourceExists(this.szLogName.ToString()) == false) Here are all the iterations of the above that do not work: if (!EventLog.SourceExists(this.szLogName)) if (EventLog.SourceExists(this.szLogName) == false)
0
9001
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9584
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9345
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9257
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8265
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6811
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2227
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.