NET Logging Library
Logging to Email
Basic Tasks > Logging to Email

The Email target sends an email for each message.  It is useful when critical issues occur. Buffering may also make sense for this type of target.

It has these properties that can be configured:

 

//Example runtime configuration, can also use log.config, app.config, or web.config
Log.ResetConfiguration();

// Initialize email target
EmailTarget target = new EmailTarget();
target.SmtpServer = "mail.example.com";
target.SmtpPort = 25;           
target.FromEmail = "testemail@example.com";
target.ToEmail = "testemail2@example.com";
target.Bcc = "";
target.Subject = "Logging message";
target.IsBodyHtml = true;
target.UserName = "testemail@example.com";
target.Password = "secret";

Log.Config.Targets.Add(target);

Log.Debug("This is a test");