本文整理汇总了C#中ObservableEventListener.LogToEmail方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableEventListener.LogToEmail方法的具体用法?C# ObservableEventListener.LogToEmail怎么用?C# ObservableEventListener.LogToEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableEventListener
的用法示例。
在下文中一共展示了ObservableEventListener.LogToEmail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
ObservableEventListener listener = new ObservableEventListener();
listener.EnableEvents(MyCompanyEventSource.Log, EventLevel.LogAlways, Keywords.All);
listener.LogToConsole();
// Modify these settings to match your SMTP service requirements.
listener.LogToEmail("smtp.live.com", 587, "[email protected]", "In Proc Sample", "etw");
MyCompanyEventSource.Log.Failure("No response from servers, general network failure!!");
listener.DisableEvents(MyCompanyEventSource.Log);
listener.Dispose();
}
示例2: Start
public void Start(TflProcess process) {
if (_started)
return;
_started = true;
Name = process.Name;
foreach (var log in process.Log) {
switch (log.Provider) {
case "file":
log.Folder = log.Folder.Replace('/', '\\');
log.File = log.File.Replace('/', '\\');
log.Folder = (log.Folder.Equals(Common.DefaultValue) ? "logs" : log.Folder).TrimEnd('\\') + "\\";
log.File = (log.File.Equals(Common.DefaultValue) ? "tfl-" + process.Name + ".log" : log.File).TrimStart('\\');
var fileListener = new ObservableEventListener();
fileListener.EnableEvents(TflEventSource.Log, (EventLevel)Enum.Parse(typeof(EventLevel), log.Level));
SinkSubscriptions.Add(fileListener.LogToRollingFlatFile(log.Folder + log.File, 5000, "yyyy-MM-dd", RollFileExistsBehavior.Increment, RollInterval.Day, new LegacyLogFormatter(), 0, log.Async));
EventListeners.Add(fileListener);
break;
case "mail":
if (log.Subject.Equals(Common.DefaultValue)) {
log.Subject = process.Name + " " + log.Level;
}
var mailListener = new ObservableEventListener();
mailListener.EnableEvents(TflEventSource.Log, EventLevel.Error);
SinkSubscriptions.Add(mailListener.LogToEmail(log));
EventListeners.Add(mailListener);
break;
}
}
}