/// <summary> /// Do Log pLogEntry /// </summary> /// <param name="pLogEntry">A LogEntry</param> /// <returns>true if successfully logged, otherwise false</returns> protected internal override bool DoLog(LogEntry pLogEntry) { string formattedLogString = Formatter.AsString(pLogEntry); FileName = FileRollOverStrategy.GetFileName(pLogEntry, formattedLogString); return(WriteToLog(formattedLogString)); }
/// <summary> /// Send the email representing aLogEntry. /// </summary> /// <param name="aLogEntry">The LogEntry.</param> /// <returns>true upon success, false upon failure.</returns> protected internal override bool DoLog(LogEntry aLogEntry) { try { String aSubject = "Subject: "; if (Subject == null) { if (aLogEntry.Application != null) { aSubject += "[" + aLogEntry.Application + "] -- "; } if (aLogEntry.Category != null) { aSubject += "{" + aLogEntry.Category + "} -- "; } aSubject += "<" + aLogEntry.SeverityString + ">"; } else { aSubject += Subject; } SmtpClient.Send(From, To, aSubject, Formatter.AsString(aLogEntry)); return(true); } catch { return(false); } }
/// <summary> /// SetForSending pLogEntry information to System.Diagnostics.Trace. /// </summary> /// <param name="pLogEntry">A LogEntry.</param> /// <returns>true upon success, false upon failure.</returns> protected internal override bool DoLog(LogEntry pLogEntry) { try { Trace.WriteLine( Formatter.AsString(pLogEntry), (pLogEntry.Category != null ? pLogEntry.Category.ToString() : null)); return(true); } catch { return(false); } }
/// <summary> /// Write aLogEntry information to the Windows event log /// </summary> /// <param name="aLogEntry">The LogEntry being logged</param> /// <returns>true upon success, false upon failure.</returns> protected internal override bool DoLog(LogEntry aLogEntry) { // convert the log entry's severity to an appropriate type for the event log EventLogEntryType t = (aLogEntry.Severity < LogSeverity.Warning) ? EventLogEntryType.Information : (aLogEntry.Severity == LogSeverity.Warning ? EventLogEntryType.Warning : EventLogEntryType.Error); try { EventLog.WriteEntry(Formatter.AsString(aLogEntry), t); } catch { return(false); } return(true); }
/// <summary> /// Gets and Sets the Windows event log. /// </summary> //protected EventLog EventLog //{ // get { return eventLog; } // set { eventLog = value; } //} /// <summary> /// Write pLogEntry information to the Windows event log /// </summary> /// <param name="pLogEntry">The LogEntry being logged</param> /// <returns>true upon success, false upon failure.</returns> protected internal override bool DoLog(LogEntry pLogEntry) { //Timok: //EventLog should always get only high severity logs: Critical, Fatal if (pLogEntry.Severity < LogSeverity.Critical) { return(true); } //EndTimok // convert the log entry's severity to an appropriate type for the event log EventLogEntryType t = (pLogEntry.Severity < LogSeverity.Warning) ? EventLogEntryType.Information : (pLogEntry.Severity == LogSeverity.Warning ? EventLogEntryType.Warning : EventLogEntryType.Error); try { eventLog.WriteEntry(Formatter.AsString(pLogEntry), t); } catch { return(false); } return(true); }
/// <summary> /// Really log pLogEntry. (We are past filtering at this point.) /// Subclasses might want to do something more interesting and override this method. /// </summary> /// <param name="pLogEntry">The LogEntry to log</param> /// <returns>true upon success, false upon failure.</returns> protected internal virtual bool DoLog(LogEntry pLogEntry) { return(WriteToLog(Formatter.AsString(pLogEntry))); }
/// <summary> /// SetForSending the email representing pLogEntry. /// </summary> /// <param name="pLogEntry">The LogEntry.</param> /// <returns>true upon success, false upon failure.</returns> protected internal override bool DoLog(LogEntry pLogEntry) { //EmailLog should processes only high severity logs: Critical, Fatal if (pLogEntry.Severity < LogSeverity.Critical) { return(true); } //-- see if the Subject was embedeed string _subject; if (pLogEntry.Category != null) { _subject = subjectHeader + pLogEntry.Category; } else { _subject = subjectHeader + "Critical ERROR !"; } setForSendingDelegate(Path.Combine(fileFolder, Guid.NewGuid().ToString("N")), from, to, string.Empty, string.Empty, toServer, password, _subject, Formatter.AsString(pLogEntry)); return(true); }