CustomTraceListener Attributes in constructor (Logging)

Topics: Logging Application Block
Mar 3, 2015 at 4:57 PM
Hi

I'm trying to create custom trace listener. I'm using configuration tool to configure it. Everything seems to be create but I'm not able to get attributes in constructor, it always returns empty Dictionary. After the TraceData call i can see that all attributes are there and with right values.

How to get em in constructor?
    [ConfigurationElementType(typeof(CustomTraceListenerData))]
    public class SyslogTraceListener : CustomTraceListener
    {

        public SyslogTraceListener()
        {
             // this.Attributes is always empty here
        }

        protected override string[] GetSupportedAttributes()
        {
            return new[] { "Server", "Port", "Protocol", "IsEnabled" };
        }

        ...

        public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
        {
             // this.Attributes is filled by now but its already too late
        }
    }