473,698 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error tracking a windows service

What is the best way that anyone has found to capture errors inside a
windows service? It's pointless to use compilation constants, as you can't
"debug" a service very easily, and you can't pass in a command line
arguement (can you?) to tell it to do something special like capture errors
to a file while it's running. Has anyone figured out any good ways to do
this type of run-time error capturing?

Basically, if I were building a standard windows app, I'd just program it so
when certain command line arguements are passed in, the compiled code would
know to output information to a file. This saves me time from having to be
on-site and step through the code line by line. Can you do something like
that with a windows service?
Nov 21 '05 #1
5 1570
Take a look at using TraceListeners and the application configuration file.
"OpticTygre " <op********@ade lphia.net> wrote in message
news:Dc******** ************@ad elphia.com...
What is the best way that anyone has found to capture errors inside a
windows service? It's pointless to use compilation constants, as you
can't "debug" a service very easily, and you can't pass in a command line
arguement (can you?) to tell it to do something special like capture
errors to a file while it's running. Has anyone figured out any good ways
to do this type of run-time error capturing?

Basically, if I were building a standard windows app, I'd just program it
so when certain command line arguements are passed in, the compiled code
would know to output information to a file. This saves me time from
having to be on-site and step through the code line by line. Can you do
something like that with a windows service?

Nov 21 '05 #2

"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:OO******** ******@TK2MSFTN GP12.phx.gbl...
Take a look at using TraceListeners and the application configuration file.

"OpticTygre " <op********@ade lphia.net> wrote in message
news:Dc******** ************@ad elphia.com...
What is the best way that anyone has found to capture errors inside a
windows service? It's pointless to use compilation constants, as you
can't "debug" a service very easily, and you can't pass in a command line arguement (can you?) to tell it to do something special like capture
errors to a file while it's running. Has anyone figured out any good ways to do this type of run-time error capturing?

Basically, if I were building a standard windows app, I'd just program it so when certain command line arguements are passed in, the compiled code
would know to output information to a file. This saves me time from
having to be on-site and step through the code line by line. Can you do
something like that with a windows service?


I just started with .net, but I've been using the application event log for
a service I've been working on. Is there a reason not to?
Nov 21 '05 #3
OpticTygre,
I currently am using a Try/Catch around my main timer routine, within the
Catch block I log any exceptions (errors) to the Event Log
(ServiceBase.Ev entLog).

As Ray suggests you could also use TraceListeners.

I am considering "upgrading" my logging to either Log4Net or the Microsoft
Enterprise Library Logging Block:

http://logging.apache.org/log4net/

http://msdn.microsoft.com/library/de...tml/entlib.asp
You can pass parameters to a service, the following example demonstrates
how.

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

Specifically Walkthrough item #7 & Figure 5, the args array to the
ServiceBase.OnS tart method is the "parameters " to the service. You set these
parameters in the properties of the Service in Computer Management under the
Windows Control Panel.

Alternatively I simply put the settings in the app.config for the service.
Depending on the needs of the service, I would consider passing the name of
the "environmen t" to as a Parameter, then used this "environmen t" parameter
as an indexer into a custom Configuration Section in my app.config... By
"environmen t" I mean: unit test, system test, QA, Production...

Hope this helps
Jay
"OpticTygre " <op********@ade lphia.net> wrote in message
news:Dc******** ************@ad elphia.com...
| What is the best way that anyone has found to capture errors inside a
| windows service? It's pointless to use compilation constants, as you
can't
| "debug" a service very easily, and you can't pass in a command line
| arguement (can you?) to tell it to do something special like capture
errors
| to a file while it's running. Has anyone figured out any good ways to do
| this type of run-time error capturing?
|
| Basically, if I were building a standard windows app, I'd just program it
so
| when certain command line arguements are passed in, the compiled code
would
| know to output information to a file. This saves me time from having to
be
| on-site and step through the code line by line. Can you do something like
| that with a windows service?
|
|
Nov 21 '05 #4
The event log is fine for things that you can easily document (stopping,
starting, exceptions during critical areas, etc...) but for debug style
traces nothing beats a good old fashioned, well formatted text file.

I have seen sooo many service type apps that try to use the vent log for
debug type tracing. Makes it a real pain in the butt to actual trace code
that way, and besides, you can really fill up someone's log file if you're
not careful.

"NetworkElf " <su**@somedomai n.com> wrote in message
news:eO******** ******@TK2MSFTN GP15.phx.gbl...

"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:OO******** ******@TK2MSFTN GP12.phx.gbl...
Take a look at using TraceListeners and the application configuration

file.


"OpticTygre " <op********@ade lphia.net> wrote in message
news:Dc******** ************@ad elphia.com...
> What is the best way that anyone has found to capture errors inside a
> windows service? It's pointless to use compilation constants, as you
> can't "debug" a service very easily, and you can't pass in a command line > arguement (can you?) to tell it to do something special like capture
> errors to a file while it's running. Has anyone figured out any good ways > to do this type of run-time error capturing?
>
> Basically, if I were building a standard windows app, I'd just program it > so when certain command line arguements are passed in, the compiled
> code
> would know to output information to a file. This saves me time from
> having to be on-site and step through the code line by line. Can you
> do
> something like that with a windows service?


I just started with .net, but I've been using the application event log
for
a service I've been working on. Is there a reason not to?

Nov 21 '05 #5

"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:uU******** ******@TK2MSFTN GP12.phx.gbl...
I have seen sooo many service type apps that try to use the vent log for
debug type tracing. Makes it a real pain in the butt to actual trace code
that way, and besides, you can really fill up someone's log file if you're
not careful.


Programming is my second hat (that's why I'm not very good at it). My first
hat is being an engineer. As you probably know, we know everything. I would
never fill up an event log... :p Thanks for the info.
Nov 21 '05 #6

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

Similar topics

0
3675
by: Jagdeesh | last post by:
Hai Colleagues, I am using Tomcat 4.1.24 and JDK 1.4.0_03 in my winXP machine. I've transferred a set of folders(containing jsp files) into tomcat's webapps directory(to /webapps/bob , /webapps/sue) and i have added the folders bob, sue in my server.xml(in the context path). When i am trying to run jsp files from my browser, it works fine. But, the following jsp files reports some exceptions which is quite hard to understand. Here is...
6
8622
by: paul calvert | last post by:
I hope somewhere here has encountered and solved a similar problem in the past. 1) on a new Win2000 PC: installed Visual C++ 6.0 download & install single file Service Pack 5.0 2) try to build my gui and dll projects, whose project, workspace, source files all resided on network drive mapped to H. The H mapping,
1
1534
by: Muddassir | last post by:
hi everybody I am writing an application for tracking files and directory changes I used FindFirstChangeNotification FindNextChangeNotification FindCloseChangeNotification ReadDirectoryChangesW
5
7368
by: HttpWebRequest | last post by:
I am trying to get tracking information from UPS web site without much luck. I got this working in VB 60 without any problems by using WinInet functions Here my test program. We need to get Tracking information from www.ups.com/ups.app/xml/track. When I tried to create the WebRequest with above ulr I get server not found. If I try www.ups.com, I do get connected but how I can post my message to ups.app/xml/track I appricate your help in...
4
7300
by: coosa | last post by:
Hi, I was installing SQL Server on my machine and during installation my PC freezed. It happens frequently on my machine. So i tried after restarting to install it again and since then i always get the same error message: "An error occurred while creating one or more registry entries. Please see C:\WINDOWS\sqlstp.log for details. The problem could be caused by a low registry quota condition" I have tried to clean the registry and i...
13
3429
by: ScottM | last post by:
I have run into a problem generating the class file via the WSDL utility. I have a WSDL file that was generated by XMLSpy and is able to be read by the Java code utility, but I get the following error from the WSDL utility. Error: Unable to import binding 'REMSOAPHttpsBinding' from namespace 'http://www.fnfis.com/services/Services-Common/REM/20040109/v1.0'. - The operation 'REMCorporationBPOOrder' on portType 'REMInterface' from...
4
6807
by: Jason Richmeier | last post by:
I am sure this has been asked at least once before but I could not find anything when searching. If I set the value of the ExitCode property to 1066 for a windows service, the text "A service specific error occured: 0." How do I (if it is possible) change the value of the zero to something custom (like a "look in the event log for further information" message)? Thank you,
7
1680
by: Jason Kester | last post by:
Best I can tell, there are three basic ways you can deal with global error handling in ASP.NET. Namely: 1. Derive all your pages from a custom Page class, and override OnError() 2. Specify a custom 500 handler in Web.Config 3. Specify a custom 500 handler in IIS
3
2513
by: =?Utf-8?B?R3JhaGFt?= | last post by:
I've added 2 tracking services to the wf runtime; one is the standard SqlTrackingService: trackingService = new SqlTrackingService(<trackingConnectionString>); <workflow Runtime>.AddService(trackingService); trackingService.IsTransactional = false; trackingService.UseDefaultProfile = true; This works just fine.
0
8683
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
8610
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
9170
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...
0
7740
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
6528
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...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
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.