How to customize Email TraceListener subject?

Topics: Logging Application Block
Aug 17, 2009 at 11:01 PM

Hi All,

For the application Logging block, the Email TraceListener subject is default to the severity level. Is there an easy way to set it to the first line of the Message?

Or I have to create a custom trace listener?

 

Thanks,

Ditto

Aug 18, 2009 at 5:54 AM

Hi,

As far as I saw the code, I would say that there is no easy way to do that. It either you modify the code of ent lib to set the subject the way you want to or just implement a custom trace listener that contains your custom logic for handling/mailing the logs.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 18, 2009 at 10:49 PM

Thanks. Valiant.

What's the best way to create EmailTraceListener alike with such minor changes?

Is there a way I can just inherit all EmailTraceListener related classes and override the necessary portion and it appears a new EmailTraceListener in Configuration console?

Thanks,

Ditto

 

Aug 19, 2009 at 5:18 AM

To answer your second question, there is no way to do that.  You have two options if you don't want to modify the entlib source code. First option is to create a simple custom tracelistener which copies the behavior of the EmailTraceListener.  The thing you might not like with this is that you can't define the properties of your custom tracelistener which you want to appear in the Properties Window.  So if you would like to have that, you would need to create classes to provide design-time support for it.  You could take a look at the source code of this authenticating email tracelistener for an example - http://www.codeplex.com/AuthEmailTraceListen.  Compile the assembly and put it in the bin installation folder of the enterprise library.  This of course entails much more effort.  It's up to you which one best suits your need.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 19, 2009 at 6:29 PM

Thanks. Sounds like the only way is to start from scratch.

Ditto