473,386 Members | 1,763 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,386 software developers and data experts.

problem trying to write to the event log

Hi having problems writing to the event log, I have the code below,
using System.Diagnostics;
System.Diagnostics.EventLog myEventLog = new System.Diagnostics.EventLog();
myEventLog.Log="newlog";
myEventLog.Source="newlog";
myEventLog.WriteEntry("another entry");
//this works but when I try
myEventLog.WriteEntry("Consoleapp1","testmessage", EventLogEntryType.Warning)
I get a compiler error-Static member 'member' cannot be accessed with an
instance reference; qualify it with a type name instead
so I tried
System.Diagnostics.EventLog.WriteEntry("Consoleapp 1","testmessage",EventLogEntryType.Warning );
this builds ok but does not seem to write to the event.
thanks.
--
Paul G
Software engineer.
Nov 16 '05 #1
2 5165
Hi Paul,
The problem is that you are specifying "Consoleapp1" as the first parameter,
yet you registered the source as "newLog".

The way you have it written, you are writing to the Application log since it
can't find the Consoleapp1 log.

Change "Consoleapp1" to "newLog" and you will be in business.

Tom Clement
Apptero, Inc.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hi having problems writing to the event log, I have the code below,
using System.Diagnostics;
System.Diagnostics.EventLog myEventLog = new
System.Diagnostics.EventLog();
myEventLog.Log="newlog";
myEventLog.Source="newlog";
myEventLog.WriteEntry("another entry");
//this works but when I try
myEventLog.WriteEntry("Consoleapp1","testmessage", EventLogEntryType.Warning)
I get a compiler error-Static member 'member' cannot be accessed with an
instance reference; qualify it with a type name instead
so I tried
System.Diagnostics.EventLog.WriteEntry("Consoleapp 1","testmessage",EventLogEntryType.Warning
);
this builds ok but does not seem to write to the event.
thanks.
--
Paul G
Software engineer.

Nov 16 '05 #2
Hi Tom, thanks for the information, working now.

"Tom Clement" wrote:
Hi Paul,
The problem is that you are specifying "Consoleapp1" as the first parameter,
yet you registered the source as "newLog".

The way you have it written, you are writing to the Application log since it
can't find the Consoleapp1 log.

Change "Consoleapp1" to "newLog" and you will be in business.

Tom Clement
Apptero, Inc.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hi having problems writing to the event log, I have the code below,
using System.Diagnostics;
System.Diagnostics.EventLog myEventLog = new
System.Diagnostics.EventLog();
myEventLog.Log="newlog";
myEventLog.Source="newlog";
myEventLog.WriteEntry("another entry");
//this works but when I try
myEventLog.WriteEntry("Consoleapp1","testmessage", EventLogEntryType.Warning)
I get a compiler error-Static member 'member' cannot be accessed with an
instance reference; qualify it with a type name instead
so I tried
System.Diagnostics.EventLog.WriteEntry("Consoleapp 1","testmessage",EventLogEntryType.Warning
);
this builds ok but does not seem to write to the event.
thanks.
--
Paul G
Software engineer.


Nov 16 '05 #3

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

Similar topics

0
by: angus | last post by:
Hi, guys, I am trying to build an event calendar using asp, i want to display a redot whenever there is an event on that day. i built the ms access database so that one day can have more than one...
8
by: Fabio Papa | last post by:
I am trying to write a windows service that sends emails to clients at specific times based on information in a sql db. Since this is done for multiple cities, I start a thread for each city and...
2
by: Brad Simon | last post by:
I have seen this problem posted, but the fix posted is not working for me, so I hope to get some help here. I am using the EMAB with all of the default settings, and no custom publisher. It...
1
by: Edward Burns | last post by:
I am trying to create an events calendar with a complete month view. I want to be able to get all the events for a particular month, using only one recordset on the page then be able to loop...
15
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A...
3
by: David | last post by:
Hi, Ive been trying to work this out for the past 2 days now and im not getting anywhere fast. The problem i have is that i am using Asynchronous sockets to create a Socket Client library....
4
by: Ben Dewey | last post by:
Hey, I have only been playing with regular expressions for some time. I am working on some code that parses and object 560 event log. I have created two expressions the first one which works...
5
by: John | last post by:
Hi I am trying to get web reference to my first (!) web service which is on a remote host. I am getting the following error; Server Error in '/' Application. Runtime Error Description: An...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
0
by: .nu | last post by:
#!/usr/bin/env python # -*- coding: utf-8 -*- # Name: Sleepy Hollow # Author: .nu import wx import os import sys
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.