logging multiple LogEntries in one step

Topics: Logging Application Block
May 11, 2009 at 11:23 AM

I want to use an EMailTraceListener to log multiple LogEntries in one step to get all entries in a singel e-mail.

How could this be achived?

Thanks in advance for any hint,

 fridi

May 11, 2009 at 12:09 PM

Hi,

Can you please provide a scenario for this? I'm quite confused, because the current behavior of the email trace listener is when a log is forwarded to the Email trace listener it will create a email for that and send it. and as you've described, do you mean that you want your log entries to be saved first for a time then later put them all together to one email then send it? or do you want that the email trace listener to read log entries from lets say a file?

Valiant Dudan
Global Technology & Solutions
Avanade, Inc.

entlib.support@avanade.com

May 11, 2009 at 12:32 PM
Edited May 11, 2009 at 1:14 PM

Hi,

yes I mean the first scenario.

I have a service that runs some tasks once a day controlled by a timer. For each task, one or more log entries are created depending on the results of the tasks. After running the tasks, the app sleeps for the rest of the day.

So I would like to save the log entries until all the tasks are finiesh for that day and then send one e-mail with all the log information.

 

i.e.(pseudo code)

 

RunTasks() {

   foreach (Task mytask in tasks) {

      ... do something

      SaveLog();

   }

   SendAllLogsInOneMail()

}

 

thanks, fridi

May 12, 2009 at 4:34 AM

The behavior you want is not configurable in EmailTraceListener.  You're gonna have to go with Valiant's suggestion, log them to a file, read its contents when all the tasks are finished and put it in a mail.  Or you can turn the contents of the file into an instance of a LogEntry and then log it using EmailTraceListener.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

entlib.support@avanade.com