How to write custom trace listener to write message logs in msmq?
WCF Custom trace listener to write logs in msmq without EnterpriseLibrary
835 Views Asked by Rohit Sonaje At
2
There are 2 best solutions below
1

If you are in code hosted by MSMQ and want to write a message to say a log file All .NET applications are the same as far as System.Diagnostics is concerned. Configure the listener in app.config, and use Trace or TraceSource to write to the listener. MSDN explains this better than I can.
If you want a trace listener that sends message to MSMSQ Get this utility library, Essential Diagnostics, that makes working with System.Diagnostics less painful
Override the one TraceEvent() method on BaseTraceListener. Inside that method, you use the available parameters to send messages to whatever you'd like, for example an MSMQ destination.
Register your custom TraceListener in the usual way.
I have added below custom MSMQTraceListener :
And updated below diagnostic setting in my web.config file: