Note that there are some explanatory texts on larger screens.

plurals
  1. POEnterprise Library Logging: Custom trace listener which sends messages to arbitrary WCF endpoint
    primarykey
    data
    text
    <p>I'm trying to write a custom trace listener for Enterprise Library Logging which sends all log messages to an arbitrary WCF endpoint. The idea behind this is that I can set up a simple console app, etc at the other end which prints out all log messages in real time.</p> <p>My question is in two parts:</p> <ol> <li>Is there a mechanism to do this already? I already looked at the MSMQ listener and I'm not interested in using that because I may have a need to use a different protocol/binding at some point.</li> <li>The way I have it implemented below - is it efficient enough or is there a better way? My concern is that every time a message comes through from the Logger (which may be frequent) I'm opening a new channel and then slamming it shut. Will this cause performance issues?</li> </ol> <p>In my sample <code>RemoteClient</code> derives from <code>ClientBase&lt;T&gt;</code>.</p> <pre><code>[ConfigurationElementType(typeof(CustomTraceListenerData))] public class RemoteTraceListener : CustomTraceListener { public override void Write(string message) { RemoteClient client = new RemoteClient(); client.Open(); client.Write(message); client.Close(); } public override void WriteLine(string message) { RemoteClient client = new RemoteClient(); client.Open(); client.WriteLine(message); client.Close(); } public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data) { if (data is LogEntry &amp;&amp; this.Formatter != null) { WriteLine(this.Formatter.Format(data as LogEntry)); } else { WriteLine(data.ToString()); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload