C# 写系统日志

 public class SystemEventLog

    {

        private static EventLog mLog;

        /// <summary>

        /// 返回操作Windows日志的类。

        /// </summary>

        public static EventLog Log

        {

            get

            {

                if (mLog == null)

                {

                    InitSystemEventLog();

                }

                return mLog;

            }

        }



        /// <summary>

        /// 初始化系统事件日志

        /// </summary>

        private static void InitSystemEventLog()

        {

            string sEventLogSource = "FDC";

            if (!EventLog.SourceExists(sEventLogSource))

            {

                EventLog.CreateEventSource(sEventLogSource, "FDCLOG");

                new EventLog("FDCLOG").MaximumKilobytes = 500 * 1024;

            }

            mLog = new EventLog();

            mLog.Source = sEventLogSource;

        }

    }

你可能感兴趣的:(C#)