当前位置: 首页>>代码示例>>C#>>正文


C# EventLogEntryType.ToString方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:ThomasGille,项目名称:Agence-immobili-re,代码行数:34,代码来源:Log.cs

示例2: WriteLine

 public override void WriteLine(EventLogEntryType type, string message)
 {
     lock (_trace)
     {
         _trace.WriteLine(message, type.ToString());
     }
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:7,代码来源:XmlFileLogging.cs

示例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
        }
开发者ID:Cogitarian,项目名称:el2sl,代码行数:56,代码来源:FormJT2SL.cs

示例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;
 }
开发者ID:JonasSyrstad,项目名称:Stardust,代码行数:13,代码来源:LoggingImplementation.cs

示例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
     {
     }
 }
开发者ID:seatre,项目名称:DbSync,代码行数:14,代码来源:Logging.cs

示例6: SetLoggingFacilityPriority

 public void SetLoggingFacilityPriority(EventLog eventLog, EventLogEntryType eventLogEntryType, SyslogFacilityPriorityPair sfpp)
 {
     _registry.Write(eventLog.Log, eventLogEntryType.ToString() + "FP", sfpp.AsInt());
 }
开发者ID:Cogitarian,项目名称:el2sl,代码行数:4,代码来源:El2SlConfig.cs

示例7: SetLoggingEnabled

 public void SetLoggingEnabled(EventLog eventLog, EventLogEntryType eventLogEntryType, bool value)
 {
     _registry.Write(eventLog.Log, eventLogEntryType.ToString() + "Enabled", value);
 }
开发者ID:Cogitarian,项目名称:el2sl,代码行数:4,代码来源:El2SlConfig.cs

示例8: LoggingFacilityPriority

 public SyslogFacilityPriorityPair LoggingFacilityPriority(EventLog eventLog, EventLogEntryType eventLogEntryType)
 {
     return SyslogFacilityPriorityPair.ConvertIntToPair(_registry.Read(eventLog.Log, eventLogEntryType.ToString() + "FP", SyslogFacilityPriorityPair.ConvertPairToInt(16,6)));
 }
开发者ID:Cogitarian,项目名称:el2sl,代码行数:4,代码来源:El2SlConfig.cs

示例9: LoggingEnabled

 public bool LoggingEnabled(EventLog eventLog, EventLogEntryType eventLogEntryType)
 {
     return _registry.Read(eventLog.Log, eventLogEntryType.ToString() + "Enabled", false);
 }
开发者ID:Cogitarian,项目名称:el2sl,代码行数:4,代码来源:El2SlConfig.cs

示例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}");
            }

        }
开发者ID:CreatorDev,项目名称:DeviceServer,代码行数:13,代码来源:ApplicationEventLog.cs

示例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);
         }
     }
 }
开发者ID:rossmas,项目名称:aws-sdk-net,代码行数:13,代码来源:DynamoDBTraceListener.cs

示例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());
        }
开发者ID:ryanski44,项目名称:VM-Automation-Framework,代码行数:20,代码来源:TestJobManagerService.cs

示例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());
        }
开发者ID:ryanski44,项目名称:VM-Automation-Framework,代码行数:19,代码来源:TestJobManagerService.cs

示例14: WriteLog

 public void WriteLog(EventLogEntryType messageType, string message)
 {
     Debug.WriteLine(String.Format("{0}: {1}", messageType.ToString(), message));
 }
开发者ID:maxrogoz,项目名称:COSystemArchitect,代码行数:4,代码来源:DebugOutputLogger.cs

示例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
            }
        }
开发者ID:bdibley,项目名称:winsw,代码行数:27,代码来源:Main.cs


注:本文中的EventLogEntryType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。