You need to create an EmailTraceListener and then add it to the collection of TraceSources for your Category.
In this example I have a base trace listener pointing to a flat file.
<add fileName="trace.log" header="----------------------------------------"
footer="----------------------------------------" formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="FlatFile TraceListener" />
With a category source as the following:
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</add>
</categorySources>
Then using code I am able to add an EmailTraceListener to the TraceSources collection.
var emailTraceListener = new EmailTraceListener("[email protected]", "[email protected]", "Food", "Bar",
"smtp.foo.bar") {Name = "EmailTraceListener"};
LogSource logSource;
Logger.Writer.TraceSources.TryGetValue("General", out logSource);
logSource.Listeners.Add(emailTraceListener);
var logEntry = new LogEntry {Message = "Test"};
Logger.Write(logEntry);
Running this example then will produce an email with the LogEntry information as well as an entry in the log file trace.log