I have a windows service that generates logs as it does some execution. I also do console.writeline
call for every log message I write into the log file. But since its a windows service the console.write line is not visible.
I want to write a C# console application program that can attach to my service (already running) and it could just show all console.writeline
messages that the process (my windows service) is generating.
updated: The volume of log is very frequent ( 50 messages every minute) , I would prefer not want to crowd windows event log for this. Using a cosole window helps to look at logs and exit on convenience
Displaying a window from a service is not a good idea as you would have to find out the "correct" session (Windows allows several users to be logged on) and also requires the service to have access to the user's desktop.
Instead, it is probably easiest to change the Console.WriteLine
calls into Trace.WriteLine
. Then you can attach to these trace messages, e.g. by using SysIntenal's DebugView.
I think you'll struggle to attach a console to an existing service. Two easy options
Re your update - number 2 would be best then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With