How can I get the trace category from TraceListener?

361 Views Asked by At

So I subclassed TraceListener in order to pipe output to EntLib6 SLAB without the need for injecting a customer logger implementation. The problem that I'm running into now is that I need to see that category that was provided with Trace.Writeline(message, category) and I'm not sure where that is. Where can I get the category from my custom TraceListener?

The end goal is really to get info from traces output in a library and send them through my actual logger in the application that consumes the library. I'm also open to any better techniques for this.

1

There are 1 best solutions below

0
On

I followed examples from https://github.com/MRCollective/AzureTraceListeners

Basically in your custom tracelistener, when you override methods like public override void WriteLine(string message, string category)

you get the category inside the method. you can pass it to your own handling method from there.