• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Log类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Log的典型用法代码示例。如果您正苦于以下问题:C# Log类的具体用法?C# Log怎么用?C# Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Log类属于命名空间,在下文中一共展示了Log类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Execute

    public static bool Execute(ProjectProperties properties, Log log)
    {
        Console.WriteLine("compiling");
        var processSettings = new ProcessStartInfo();
        processSettings.FileName = properties.CscPath;
        processSettings.Arguments = properties.FormatCscArguments();

        log.WriteLine("Executing {0}", processSettings.FileName);
        log.WriteLine("Csc Arguments: {0}", processSettings.Arguments);

        processSettings.CreateNoWindow = true;
        processSettings.RedirectStandardOutput = true;
        processSettings.UseShellExecute = false;

        Process cscProcess = null;
        try
        {
            cscProcess = Process.Start(processSettings);
        }
        catch (Win32Exception)
        {
            Console.WriteLine("ERROR: csc.exe needs to be on the path.");
            return false;
        }

        var output = cscProcess.StandardOutput.ReadToEnd();
        log.WriteLine(output);

        cscProcess.WaitForExit();

        if (output.Contains("error CS")) return false;
        return true;
    }
开发者ID:dalbanhi,项目名称:corefxlab,代码行数:33,代码来源:dotnet.cs


示例2: Start

        public void Start()
        {
            if (_running)
                throw new InvalidOperationException("Process is already running");

            if (!string.IsNullOrEmpty(LogFile))
            {
                _log = new Log(LogFile, BufferSize, ReliableLogging);
                _log.MaxNumberBackups = MaxNumberOfLogBackups;
                _log.MaxSize = MaxLogSize;
            }

            _process = new Process();
            _process.StartInfo.CreateNoWindow = true;
            _process.StartInfo.RedirectStandardError = true;
            _process.StartInfo.RedirectStandardInput = true;
            _process.StartInfo.RedirectStandardOutput = true;
            _process.StartInfo.UseShellExecute = false;
            _process.StartInfo.FileName = ImagePath;
            _process.StartInfo.Arguments = Arguments
                .Select(a => a.Replace("\"", "\\\""))
                .Select(a => a.Contains(" ") ? "\"" + a + "\"" : a)
                .Aggregate(new StringBuilder(), (sb, a) => sb.Append(a).Append(' '))
                .ToString()
                .Trim();
            _process.StartInfo.WorkingDirectory = WorkingDirectory;

            _process.ErrorDataReceived += new DataReceivedEventHandler(_process_OutputDataReceived);
            _process.OutputDataReceived += new DataReceivedEventHandler(_process_OutputDataReceived);
            _process.Exited += new EventHandler(_process_Exited);
            _process.Start();
            _process.BeginErrorReadLine();
            _process.BeginOutputReadLine();
            _running = true;
        }
开发者ID:authorunknown,项目名称:mtools,代码行数:35,代码来源:ExternalProcess.cs


示例3: FrmBaseTableView

        private DataTable dataTable;     // загруженная таблица


        /// <summary>
        /// Конструктор
        /// </summary>
        private FrmBaseTableView()
        {
            InitializeComponent();
            errLog = null;
            baseAdapter = null;
            dataTable = null;
        }
开发者ID:raydtang,项目名称:scada,代码行数:13,代码来源:FrmBaseTableView.cs


示例4: InsertInto

        /// <summary>
        /// Insert data into table
        /// e.g. DDL.InsertInto("Sample", "col1,col2", "10,20");
        /// </summary>
        /// <param name="sTableName"></param>
        /// <param name="sColumns_i"></param>
        /// <param name="sValues_i"></param>
        public static void InsertInto(string sTableName, string sColumns_i, string sValues_i )
        {
            using( Log log = new Log( "Glx.DB.DDL.InsertInto()" ) )
            {
                try
                {
                    string sQuerry = "INSERT INTO " + sTableName + "(";
                    string[] sColums = Strings.Split(sColumns_i, ",", -1, CompareMethod.Text);

                    sQuerry = sQuerry + sColums[0];

                    for (int nIndex = 1; nIndex < sColums.Length; nIndex++)
                        sQuerry = sQuerry + "," + sColums[nIndex];

                    sQuerry += ") VALUES(";

                    string[] sValues = Strings.Split(sValues_i, ",", -1, CompareMethod.Text);

                    sQuerry = sQuerry + sValues[0];

                    for (int nIndex = 1; nIndex < sValues.Length; nIndex++)
                        sQuerry = sQuerry + "," + sValues[nIndex];

                    sQuerry += ")";

                    log.PutQuerry( sQuerry);
                    DBWrapper.ExecuteNonQueryEx(sQuerry);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }
        }
开发者ID:jithinputhiyattu,项目名称:dreamFrameWork,代码行数:41,代码来源:DDL.cs


示例5: Write

		/// <summary>
		/// Writes a single message to the output.
		/// </summary>
		/// <param name="source">The <see cref="Log"/> from which the message originates.</param>
		/// <param name="type">The type of the log message.</param>
		/// <param name="msg">The message to write.</param>
		/// <param name="context">The context in which this log was written. Usually the primary object the log entry is associated with.</param>
		public virtual void Write(Log source, LogMessageType type, string msg, object context)
		{
			int indent = source.Indent;
			string prefix = source.Prefix ?? "";
			string[] lines = msg.Split(new[] { '\n', '\r', '\0' }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < lines.Length; i++)
			{
				if (i == 0)
				{
					switch (type)
					{
						case LogMessageType.Message:
							lines[i] = prefix + "Msg: " + new string(' ', indent * 2) + lines[i];
							break;
						case LogMessageType.Warning:
							lines[i] = prefix + "Wrn: " + new string(' ', indent * 2) + lines[i];
							break;
						case LogMessageType.Error:
							lines[i] = prefix + "ERR: " + new string(' ', indent * 2) + lines[i];
							break;
					}
				}
				else
				{
					lines[i] = new string(' ', prefix.Length + 5 + indent * 2) + lines[i];
				}

				this.WriteLine(source, type, lines[i], context);
			}
		}
开发者ID:Scottyaim,项目名称:duality,代码行数:37,代码来源:TextWriterLogOutput.cs


示例6: PostScheduleMessage

        public override void PostScheduleMessage(dynamic data)
        {
            try
            {

                oAuthTwitter OAuthTwt = new oAuthTwitter();
                TwitterAccountRepository fbaccrepo = new TwitterAccountRepository();
                TwitterAccount twtaccount = fbaccrepo.getUserInformation(data.UserId, data.ProfileId);


                OAuthTwt.CallBackUrl = System.Configuration.ConfigurationSettings.AppSettings["callbackurl"];
                OAuthTwt.ConsumerKey = System.Configuration.ConfigurationSettings.AppSettings["consumerKey"];
                OAuthTwt.ConsumerKeySecret = System.Configuration.ConfigurationSettings.AppSettings["consumerSecret"];
                OAuthTwt.AccessToken = twtaccount.OAuthToken;
                OAuthTwt.AccessTokenSecret = twtaccount.OAuthSecret;
                OAuthTwt.TwitterScreenName = twtaccount.TwitterScreenName;
                OAuthTwt.TwitterUserId = twtaccount.TwitterUserId;


                #region For Testing
                // For Testing 

                //OAuthTwt.ConsumerKey = "udiFfPxtCcwXWl05wTgx6w";
                //OAuthTwt.ConsumerKeySecret = "jutnq6N32Rb7cgbDSgfsrUVgRQKMbUB34yuvAfCqTI";
                //OAuthTwt.AccessToken = "1904022338-Ao9chvPouIU8ejE1HMG4yJsP3hOgEoXJoNRYUF7";
                //OAuthTwt.AccessTokenSecret = "Wj93a8csVFfaFS1MnHjbmbPD3V6DJbhEIf4lgSAefORZ5";
                //OAuthTwt.TwitterScreenName = "";
                //OAuthTwt.TwitterUserId = ""; 
                #endregion

                TwitterUser twtuser = new TwitterUser();

                if (string.IsNullOrEmpty(data.ShareMessage))
                {
                    data.ShareMessage = "There is no data in Share Message !";
                }

                JArray post = twtuser.Post_Status_Update(OAuthTwt, data.ShareMessage);

                
             
                Console.WriteLine("Message post on twitter for Id :" + twtaccount.TwitterUserId + " and Message: " + data.ShareMessage);
                ScheduledMessageRepository schrepo = new ScheduledMessageRepository();
                schrepo.updateMessage(data.Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                Log log = new Log();
                log.CreatedDate = DateTime.Now;
                log.Exception = ex.Message;
                log.Id = Guid.NewGuid();
                log.ModuleName = "TwitterScheduler";
                log.ProfileId = data.ProfileId;
                log.Status = false;
                LogRepository logRepo = new LogRepository();
                logRepo.AddLog(log);
            }

        }
开发者ID:JBNavadiya,项目名称:socioboard,代码行数:60,代码来源:TwitterScheduler.cs


示例7: getInstance

	public static Log getInstance() {
		if (Log.s_instance == null) {
			Log.s_instance = new Log();
			Log.s_instance.Initialize();
		}
		return Log.s_instance;
	}
开发者ID:moto2002,项目名称:UExtend,代码行数:7,代码来源:Log.cs


示例8: fmMain_Load

        private void fmMain_Load(object sender, EventArgs e)
        {
            bool r;
            AppMutex = new Mutex(true, "AndonSys.AppHelper", out r);
            if (!r)
            {
                MessageBox.Show("系统已运行!",this.Text);
                Close();
                return;
            }
            
            CONFIG.Load();

            log = new Log(Application.StartupPath, "AppHelper", Log.DEBUG_LEVEL);

            log.Debug("系统运行");
           
            gdApp.AutoGenerateColumns = false;
           
            LoadApp();
            
            tbApp.Show();

            timer.Enabled = true;
        }
开发者ID:puyd,项目名称:AndonSys.Test,代码行数:25,代码来源:fmAppHelper.cs


示例9: VariantValidate

        /// <summary>
        /// Validates a variant string, returns true if variant string is a correct HVGS nomnclature
        /// </summary>
        /// <param name="variant"></param>
        /// <returns></returns>
        public bool VariantValidate(string variant)
        {
            try
            {
                Process process = new Process();
                if (ApplicationDeployment.IsNetworkDeployed)
                    process.StartInfo.FileName = ApplicationDeployment.CurrentDeployment.DataDirectory + "\\Executables\\Validator.exe";
                else
                    process.StartInfo.FileName = Application.StartupPath + "\\Executables\\Validator.exe";
                process.StartInfo.Arguments = "-v " + "\"" + variant + "\"";
                process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.RedirectStandardOutput = true;

                process.Start();
                string output = process.StandardOutput.ReadToEnd();
                process.WaitForExit();
                process.Close();

                return bool.Parse(output);
            }
            catch (Exception ex)
            {
                // something went wrong, we log it
                Log log = new Log(true);
                log.write("Error parsing variant: " + variant);
                log.write(ex.ToString());
                return false;
            }
        }
开发者ID:HVPA,项目名称:VariantExporter,代码行数:36,代码来源:Validator.cs


示例10: connect_util

        private void connect_util()
        {
            string user_name, password;
            int id_user = 0;
            user_name = user_name_txt.Text != "" ? user_name_txt.Text : "";
            password = password_txt.Text != "" ? password_txt.Text : "";

            id_user = db_util.query_user(user_name, password);

            if (id_user != 0)
            {
                log = new Log(id_user);
                log.id_log = db_util.insert_log(log);

                MainWindow main_window = new MainWindow();
                main_window.log = log;
                main_window.db_util = db_util;
                main_window.Show();
                this.Close();
            }
            else
            {
                info_lbl.Content = "Something went wrong!\nTry again";
            }
        }
开发者ID:KTwo,项目名称:BA,代码行数:25,代码来源:Login.xaml.cs


示例11: ExecuteAppendLog

        public void ExecuteAppendLog(Log log)
        {
            string path = string.Format("../../{0}", this.LogFile);

            try
            {
                if (!File.Exists(path))
                {
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(path))
                    {
                        file.WriteLine(layout.Format(log));
                    }
                }
                else if (File.Exists(path))
                {
                    using (TextWriter textWriter = new StreamWriter(path, true))
                    {
                        textWriter.WriteLine(layout.Format(log));
                        textWriter.Close();
                    }
                }
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:PlamenaMiteva,项目名称:Quality-Programming-Code,代码行数:27,代码来源:FileAppender.cs


示例12: CanCreateAlarmTypeAndLog

        public void CanCreateAlarmTypeAndLog()
        {
            IRepository<AlarmType> repoA = new AlarmTypeRepository();
            AlarmType alarm = new AlarmType();
            alarm.NameAlarmType = "PruebaAlarma";
            alarm.Description = "Prueba descriptiva alarma";

            repoA.Save(alarm);

            IRepository<User> repoB = new UserRepository();
            User user = new User();
            user = repoB.GetById(1);
            IRepository<Event> repoC = new EventRepository();
            Event eventt = new Event();
            eventt = repoC.GetById(2);

            IRepository<Log> repoD = new LogRepository();
            Log log = new Log();
            log.DateTime = DateTime.Now;
            log.Text = "Prueba descriptiva log";
            log.Event = eventt;
            log.User = user;

            repoD.Save(log);
        }
开发者ID:diegotrujillor,项目名称:SMCL,代码行数:25,代码来源:UnitTest2.cs


示例13: GetSnoPoMo

        static public string GetSnoPoMo(SqlConnection connect,
                                                                        Log log,
                                                                        string productId)
        {
            string ret = null;

            SqlCommand dbCmd = connect.CreateCommand();
            dbCmd.CommandType = CommandType.Text;
            dbCmd.CommandText = "select top 1 PO from dbo.SnoDet_PoMo (nolock) where [email protected]";
            SQLHelper.createInputSqlParameter(dbCmd, "@SnoId", 10, productId);


            log.write(LogType.Info, 0, "SQL", "GetSnoPoMo", dbCmd.CommandText);
            log.write(LogType.Info, 0, "SQL", "@SnoId", productId);
           


            SqlDataReader sdr = dbCmd.ExecuteReader();
            while (sdr.Read())
            {
                ret=sdr.GetString(0).Trim();
            }
            sdr.Close();
            return ret;
        }
开发者ID:wra222,项目名称:testgit,代码行数:25,代码来源:SQLStatement.cs


示例14: GetCNRSSNList

        static public List<string> GetCNRSSNList(SqlConnection connect,
                                                                            Log log,
                                                                            int offsetDay)
        {
            List<string> SNList = new List<string>();

            SqlCommand dbCmd = connect.CreateCommand();
            dbCmd.CommandType = CommandType.Text;
            dbCmd.CommandText = @"select distinct a.SnoId
                                                            from Special_Det a
                                                            left join ProductAttr b on (a.SnoId = b.ProductID and b.AttrName='CNRSState')
                                                            where a.Tp='CNRS' 
	                                                            and a.Udt>=dateadd(dd,@day,getdate())
	                                                            and b.AttrValue is null";

            SQLHelper.createInputSqlParameter(dbCmd, "@day", offsetDay);


            log.write(LogType.Info, 0, "SQL", "GetCNRSSNList", dbCmd.CommandText);
            log.write(LogType.Info, 0, "SQL", "@day", offsetDay.ToString());



            SqlDataReader sdr = dbCmd.ExecuteReader();

            while (sdr.Read())
            {
                SNList.Add(sdr.GetString(0).Trim());
            }
            sdr.Close();
            return SNList;
        }
开发者ID:wra222,项目名称:testgit,代码行数:32,代码来源:SQLStatement.cs


示例15: GetCDSISNList

        static public List<string> GetCDSISNList(SqlConnection connect,
                                                                                Log log,
                                                                                string snoId,
                                                                                string tp)
       {
          List<string> SNList = new List<string>();
 
          SqlCommand dbCmd = connect.CreateCommand();
          dbCmd.CommandType = CommandType.StoredProcedure;
          dbCmd.CommandText = "op_CDSIDataUpdate";
          SQLHelper.createInputSqlParameter(dbCmd, "@SnoId", 10, snoId);
          SQLHelper.createInputSqlParameter(dbCmd, "@tp", 2, tp);

          log.write(LogType.Info, 0, "SQL", "GetDNList", dbCmd.CommandText);
          log.write(LogType.Info, 0, "SQL", "@SnoId", snoId);
          log.write(LogType.Info, 0, "SQL", "@tp", tp);


         SqlDataReader sdr = dbCmd.ExecuteReader();
         while (sdr.Read())
         {
            SNList.Add(sdr.GetString(0).Trim());          
         }
         sdr.Close();
         return SNList;
       }
开发者ID:wra222,项目名称:testgit,代码行数:26,代码来源:SQLStatement.cs


示例16: Log

        /// <summary>
        /// Log a message.
        /// </summary>
        /// <param name="message">Message to log. </param>
        /// <param name="level">Error severity level. </param>
        public void Log(Log.Level level, string message)
        {
            FileStream fileStream = null;
            StreamWriter writer = null;
            StringBuilder messageBuilder = new StringBuilder();

            try
            {
                fileStream = _logFile.Open(FileMode.OpenOrCreate,
                          FileAccess.Write, FileShare.Read);
                writer = new StreamWriter(fileStream);

                // Set the file pointer to the end of the file
                writer.BaseStream.Seek(0, SeekOrigin.End);

                // Create the message
                messageBuilder.Append(System.DateTime.Now.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss"))
                   .Append(" | ").Append(level.ToString()).Append(" | ").Append(message);

                // Force the write to the underlying file
                writer.WriteLine(messageBuilder.ToString());
                writer.Flush();
            }
            finally
            {
                if (writer != null) 
                    writer.Close();
            }
        }
开发者ID:EarlBoss,项目名称:picasastarter,代码行数:34,代码来源:FileLogger.cs


示例17: LoggerService

 /// <summary>
 /// Initializes a new instance of the <see cref="LoggerService"/> class.
 /// </summary>
 public LoggerService()
 {
     InitializeComponent();
     Server = new TcpLoggerServer(4000);
     ConnectedClients = new Dictionary<string, LogMessageHandler>();
     LogWriter = new Log();
 }
开发者ID:rajeshssem,项目名称:RemoteLoggerServer,代码行数:10,代码来源:LoggerService.cs


示例18: DerivativeTest1

        public void DerivativeTest1()
        {
            IExpression exp = new Log(new Variable("x"), new Number(2));
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("1 / (x * ln(2))", deriv.ToString());
        }
开发者ID:ronnycsharp,项目名称:xFunc,代码行数:7,代码来源:LogTest.cs


示例19: Send

        public static void Send(string mailFrom,
                                                    string[] mailTo,
                                                    string[] mailCC,
                                                    string mailSubject,
                                                    string mailBody,
                                                    string mailServer,
                                                     Log log)
        {
            try
            {
                MailMessage mailMsg = new MailMessage();

                if (string.IsNullOrEmpty(mailSubject) || mailTo.Length == 0)
                    return;

                mailMsg.From = new MailAddress(mailFrom);

                if (mailTo.Length > 0)
                {
                    for (int i = 0; i < mailTo.Length; ++i)
                    {
                        if (mailTo[i].Trim().Length > 0)
                        {
                            mailMsg.To.Add(new MailAddress(mailTo[i]));
                        }
                    }
                }


                if (mailCC.Length > 0)
                {
                    for (int i = 0; i < mailCC.Length; ++i)
                    {
                        if (mailCC[i].Trim().Length > 0)
                        {
                            mailMsg.CC.Add(new MailAddress(mailCC[i]));
                        }
                    }
                }



                mailMsg.Subject = mailSubject;
                mailMsg.Body = mailBody;
                mailMsg.IsBodyHtml = true;

                SmtpClient client = new SmtpClient(mailServer, 25);
                if (mailMsg.To.Count > 0)
                {
                    client.Send(mailMsg);
                }

            }
            catch (Exception e)
            {
                log.write(LogType.error, 0, "sendMail", "->", e.StackTrace);
                log.write(LogType.error, 0, "sendMail", "->", e.Message);

            }
        }
开发者ID:wra222,项目名称:testgit,代码行数:60,代码来源:SendMail.cs


示例20: DerivativeTest3

        public void DerivativeTest3()
        {
            IExpression exp = new Log(new Number(2), new Variable("x"));
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("-(ln(2) * (1 / x)) / (ln(x) ^ 2)", deriv.ToString());
        }
开发者ID:ronnycsharp,项目名称:xFunc,代码行数:7,代码来源:LogTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Log4NetCustom.LogMessage类代码示例发布时间:2022-05-24
下一篇:
C# LockType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap