Click here to Skip to main content
12,447,786 members (63,213 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# plugin
Hi Folks!

I'm currently facing a problem and cannot figure out what's wrong.

In my application, I use a simple Plugin architecture. For debugging, I want to write text to my trace. I have set up a TraceSource within the Plugin.dll:

private static readonly TraceSource ts = new TraceSource("Plugin");

The application app.config contains:

<system.diagnostics>
  <trace autoflush="true" indentsize="4">
    <listeners>
      <add name="defaultLogListener"/>
    </listeners>
  </trace>
		
  <sources>
    <source name="Plugin" switchValue="All">
      <listeners>
	<remove name="Default"/>
	<add name="defaultLogListener"/>
      </listeners>
    </source>
  </sources>
		
  <sharedListeners>
    <add name="defaultLogListener" 
      type="System.Diagnostics.ConsoleTraceListener"
      traceOutputOptions="Timestamp"/>
  </sharedListeners>
</system.diagnostics>

Tracing from within the application works, but I don't get the messages from within the plugin.dll raised by

ts.TraceInformation("TRACE from Plugin");

What am I doing wrong? Do I have to pass a TraceSource from my application to the Plugin instead of creating a new one inside?

Thanks a lot in advance

Rowan
Posted 3-Dec-12 13:29pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Sometimes ... it's time to slap the head against the wall. Smile | :)

Just a config thing:

My Plugin TraceSource was not writing to the correct listener...

The following config works perfectly, writing to both, file and console listener:

<system.diagnostics>
  <trace autoflush="true" indentsize="4">
    <listeners>
  <add name="defaultLogListener" />
  <add name="defaultFileListener" />
    </listeners>
  </trace>
 
  <sources>
  <source name="ImporterPlugin" switchvalue="All">
    <listeners>
      <add name="defaultLogListener" />
      <add name="defaultFileListener" />
        </listeners>
  </source>
  </sources>
 
  <sharedlisteners>
  <add name="defaultLogListener">
       type="System.Diagnostics.ConsoleTraceListener"
       traceOutputOptions="Timestamp"/>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100