zoukankan      html  css  js  c++  java
  • C#写系统日志

    /// <summary>
            /// 写系统日志
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {
                string message="刘习金的测试主文本,时间"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string sourcename = "dnsinfo";
                EventLogEntryType errotype=EventLogEntryType.SuccessAudit;
                try
                {
                    EventLog mylog = new EventLog();
                    if (!EventLog.SourceExists(sourcename))
                    {
                        EventLog.CreateEventSource(sourcename, sourcename);
                    }

                    mylog.Source = sourcename;

                    mylog.MaximumKilobytes = 1024 * 20;

                    mylog.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, 30);

                    mylog.WriteEntry(message, errotype);
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

  • 相关阅读:
    [atARC088F]Christmas Tree
    [atARC109F]1D Kingdom Builder
    [luogu4259]寻找车位
    [atARC087F]Squirrel Migration
    [atARC087E]Prefix-free Game
    [atARC110F]Esoswap
    [atARC110E]Shorten ABC
    [atARC084D]Small Multiple
    [atARC083F]Collecting Balls
    [hihocoder][Offer收割]编程练习赛49
  • 原文地址:https://www.cnblogs.com/flish/p/1748241.html
Copyright © 2011-2022 走看看