本文整理汇总了C#中EventLogEntryType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# EventLogEntryType.ToString方法的具体用法?C# EventLogEntryType.ToString怎么用?C# EventLogEntryType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventLogEntryType
的用法示例。
在下文中一共展示了EventLogEntryType.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFileEventLog
private void AddFileEventLog(string message, EventLogEntryType logType = EventLogEntryType.Information, string moduleName = "", int codeErreur = 0, bool fromWindowsLogEvent = false)
{
System.IO.StreamWriter w = null;
System.Text.StringBuilder str = new System.Text.StringBuilder();
try {
string strPath = System.IO.Path.GetDirectoryName(_logFilePath);
if (!System.IO.Directory.Exists(strPath))
System.IO.Directory.CreateDirectory(strPath);
w = new System.IO.StreamWriter(_logFilePath, true, System.Text.Encoding.Default);
str.AppendFormat("[{0,-10:G} - {1,-8:G}]", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());
str.AppendFormat(" {0}", Const.DEFAULT_APPLICATION_NAME);
if (!string.IsNullOrEmpty(moduleName))
str.AppendFormat(" ({0})", moduleName);
str.AppendFormat(" - {0}", logType.ToString());
if (codeErreur != 0)
str.AppendFormat(" - Code : {0}", codeErreur);
str.Append("\r\n");
str.Append(message);
str.Append("\r\n");
w.WriteLine(str.ToString());
} catch (Exception ex) {
if (!fromWindowsLogEvent) {
AddWindowsEventLog("Impossible d'écrire dans le fichier de log : " + _logFilePath + "\r\n" + message + "\r\nException : " + ex.Message, EventLogEntryType.Error, moduleName, 0, true);
}
} finally {
if ((w != null))
w.Close();
}
}
示例2: WriteLine
public override void WriteLine(EventLogEntryType type, string message)
{
lock (_trace)
{
_trace.WriteLine(message, type.ToString());
}
}
示例3: FormJT2SL
public FormJT2SL(El2SlConfig config, EventLog eventLog, EventLogEntryType eventLogEntryType)
{
InitializeComponent();
_eventLog = eventLog;
_eventLogEntryType = eventLogEntryType;
lInfo.Text = string.Format("{0}:{1}", _eventLog.LogDisplayName, eventLogEntryType.ToString());
cbEnabled.Checked = config.LoggingEnabled(eventLog, eventLogEntryType);
cbEnabled_CheckedChanged(cbEnabled, new EventArgs());
#region Grid fill
#region Preparing Columns headers
for ( int fh = 0; fh < SFacilityes.Length; fh++ ) // columns
{
tlpFacilityPriority.ColumnCount++;
VerticalLabel lColumn = new VerticalLabel();
lColumn.Text = SFacilityes[fh];
//lColumn.TextAlign = ContentAlignment.BottomCenter;
tlpFacilityPriority.Controls.Add(lColumn, tlpFacilityPriority.ColumnCount - 1, 0);
}
#endregion
for (int pt = 0; pt < SPriorityes.Length; pt++ ) // rows
{
#region Preparing row labels
Label lRow = new Label();
lRow.Text = SPriorityes[pt];
lRow.AutoSize = true;
tlpFacilityPriority.Controls.Add(lRow, 0, tlpFacilityPriority.RowCount);
#endregion
int currentColumn = 1;
tlpFacilityPriority.RowCount++;
for (int ft = 0; ft < SFacilityes.Length; ft++) // columns
{
int fpNum = SyslogFacilityPriorityPair.ConvertPairToInt(ft, pt);
RadioButton bSelection = new RadioButton();
bSelection.Width = 16;
bSelection.Tag = fpNum;
bSelection.Checked = config.LoggingFacilityPriority(eventLog, eventLogEntryType).AsInt() ==
fpNum;
bSelection.CheckedChanged += BSelectionOnCheckedChanged;
tlpFacilityPriority.Controls.Add(bSelection, currentColumn, tlpFacilityPriority.RowCount - 1);
currentColumn++;
}
}
#endregion
}
示例4: CreateDebugMessage
private static StringBuilder CreateDebugMessage(string message, EventLogEntryType entryType, string additionalDebugInformation)
{
var sb = new StringBuilder();
sb.Append(entryType.ToString());
sb.Append(": ");
sb.Append(message);
if (additionalDebugInformation.ContainsCharacters())
{
sb.Append(" ---- Additional: ");
sb.Append(additionalDebugInformation);
}
return sb;
}
示例5: WriteMessageToApplicationLog
public static void WriteMessageToApplicationLog(string message, EventLogEntryType eventLogEntryType)
{
try
{
EventLog.WriteEntry("MySqlDataMigService", message, eventLogEntryType);
if (DebugMode)
{
Console.WriteLine("{0} : {1}", eventLogEntryType.ToString(), message);
}
}
catch
{
}
}
示例6: SetLoggingFacilityPriority
public void SetLoggingFacilityPriority(EventLog eventLog, EventLogEntryType eventLogEntryType, SyslogFacilityPriorityPair sfpp)
{
_registry.Write(eventLog.Log, eventLogEntryType.ToString() + "FP", sfpp.AsInt());
}
示例7: SetLoggingEnabled
public void SetLoggingEnabled(EventLog eventLog, EventLogEntryType eventLogEntryType, bool value)
{
_registry.Write(eventLog.Log, eventLogEntryType.ToString() + "Enabled", value);
}
示例8: LoggingFacilityPriority
public SyslogFacilityPriorityPair LoggingFacilityPriority(EventLog eventLog, EventLogEntryType eventLogEntryType)
{
return SyslogFacilityPriorityPair.ConvertIntToPair(_registry.Read(eventLog.Log, eventLogEntryType.ToString() + "FP", SyslogFacilityPriorityPair.ConvertPairToInt(16,6)));
}
示例9: LoggingEnabled
public bool LoggingEnabled(EventLog eventLog, EventLogEntryType eventLogEntryType)
{
return _registry.Read(eventLog.Log, eventLogEntryType.ToString() + "Enabled", false);
}
示例10: WriteEntry
public static void WriteEntry(string source, string message, EventLogEntryType type)
{
Action<string> levelLogger;
if (_Logger != null && _LogLevelMap.TryGetValue(type, out levelLogger))
{
levelLogger(message);
}
else
{
Console.WriteLine($"{type.ToString()}: {message}");
}
}
示例11: WriteToEventFile
// Writes event to file, if one can be written
private void WriteToEventFile(string message, EventLogEntryType logEntryType)
{
string logsFilePath = GetEventLogsFileLocation();
if (!string.IsNullOrEmpty(logsFilePath))
{
using (var stream = File.Open(logsFilePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
using (var writer = new StreamWriter(stream))
{
writer.WriteLine(eventLogsFormat, eventLogSource, logEntryType.ToString(), DateTime.Now.ToString(), message);
}
}
}
示例12: VerifyAppLogDoesNotContain
private void VerifyAppLogDoesNotContain(EventLogEntryType unExpectedLevel, DateTime minimumTime)
{
minimumTime = minimumTime.AddMilliseconds((minimumTime.Millisecond + 1) * -1);
EventLog appLog = new EventLog("Application");
bool found = false;
string message = "";
foreach (EventLogEntry entry in appLog.Entries)
{
if (entry.TimeGenerated >= minimumTime &&
entry.Source == "VM Job Manager Service" &&
entry.EntryType == unExpectedLevel)
{
found = true;
message = entry.Message;
break;
}
}
Assert.False(found, "Found unexpected event log entry \"{0}\" with severity \"{1}\" in application log", message, unExpectedLevel.ToString());
}
示例13: VerifyAppLogContainsString
private void VerifyAppLogContainsString(string expectedMessageSubString, EventLogEntryType expectedLevel, DateTime minimumTime)
{
minimumTime = minimumTime.AddMilliseconds((minimumTime.Millisecond + 1) * -1);
EventLog appLog = new EventLog("Application");
bool found = false;
foreach (EventLogEntry entry in appLog.Entries)
{
if (entry.TimeGenerated >= minimumTime &&
entry.Source == "VM Job Manager Service" &&
entry.EntryType == expectedLevel &&
entry.Message.Contains(expectedMessageSubString))
{
found = true;
break;
}
}
Assert.True(found, "Could not find event log entry with message \"{0}\" and severity \"{1}\" in application log", expectedMessageSubString, expectedLevel.ToString());
}
示例14: WriteLog
public void WriteLog(EventLogEntryType messageType, string message)
{
Debug.WriteLine(String.Format("{0}: {1}", messageType.ToString(), message));
}
示例15: LogEvent
public void LogEvent(String message, EventLogEntryType type)
{
if (systemShuttingdown)
{
/* NOP - cannot call EventLog because of shutdown. */
}
else
{
try
{
EventLog.WriteEntry(message, type);
}
catch (Exception e)
{
// ignore logging exceptions
}
}
try
{
WriteEventToLogFile("[" + type.ToString() + "] " + message);
}
catch (Exception e)
{
// ignore logging exceptions
}
}