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.EventLog).
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.OnStart 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 "environment" to as a Parameter, then used this "environment" parameter
as an indexer into a custom Configuration Section in my app.config... By
"environment" I mean: unit test, system test, QA, Production...
Hope this helps
Jay
"OpticTygre" <op********@adelphia.net> wrote in message
news:Dc********************@adelphia.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?
|
|