Problem with Custom Trace Listener Configuration

Topics: Logging Application Block
Oct 15, 2008 at 11:07 AM
Hello,

I created a Custom Trace Listener DLL and followed the approach described at
http://msdn.microsoft.com/en-us/library/cc511727.aspx

When I want to use the created DLL and try to include it via Enterprise Library Configuration / Trace Listener I get the error message "There were no types found in the assembly 'xxx' that implement or inherit from the base type 'Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.CustomTraceListener'.". After searching for this message I figured out that it might be a problem of the Configuration Tool. So, I like to extend the Configuration XML file manually, but so far I son't have success doing that.

I added the following lines:
  <add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
   traceOutputOptions="None" filter="All" type="DLWebServiceTraceListener"
   name="Custom Trace Listener" initializeData="" />

but that doesn't seem to work (I guess the listenerDataType is wrong, but I cannot fix it), I get this error message:

The type 'DLWebServiceTraceListener' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.

The DLL is stored in the bin directory and here is my DLL code:

namespace

 

DLWebServiceTraceListener

 

{

[

ConfigurationElementType(typeof(CustomTraceListenerData))]

 

 

public class DLWebServiceTraceListener : CustomTraceListener

 

{

 

public override void Write(string message)

 

{

 

Service1 service = new Service1();

 

 

Debug.Write(service.HelloWorld());

 

 

Debug.Write(message);

 

}

 

public override void WriteLine(string message)

 

{

 

Debug.WriteLine(message);

 

}

 

public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)

 

{

 

if (data is LogEntry && this.Formatter != null)

 

{

 

this.WriteLine(this.Formatter.Format(data as LogEntry));

 

}

 

else

 

{

 

this.WriteLine(data.ToString());

 

}

}

}

}


Does anybody know where the problem is ? Or is there even an existing Custom WebService for the Logging Application Block available?

Thanks
Daniel
Oct 16, 2008 at 4:49 AM
I also followed the walkthrough and it worked fine.  See this post. http://www.codeplex.com/Thread/View.aspx?ProjectName=entlib&ThreadId=13191.  The suggestion there is that you may have versioning problems.
Oct 16, 2008 at 12:05 PM
Hello,

thanks for your answer, it helped me to figure out the problem. I didn't reference the DLLs from C:\Program Files\Microsoft Enterprise Library 4.0 - May 2008\Bin
I used a different directory and so I got versioning problems...

Just for reference if other people want to add a custom tracer manually here is the new entry in the App.config:

      <add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="DLWebServiceTraceListener.DLWebServiceTraceListener, DLWebServiceTraceListener, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
        name="Custom Trace Listener" initializeData="" />

Regards
Daniel