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


C# Level.ToString方法代码示例

本文整理汇总了C#中log4net.Core.Level.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Level.ToString方法的具体用法?C# Level.ToString怎么用?C# Level.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在log4net.Core.Level的用法示例。


在下文中一共展示了Level.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetLoggingLevel

        /// <summary>
        /// Sets logging level for all current loggers to the level provided in arguments.
        /// Note: use it only when you need more control on logging, e.g. in unit tests. Otherwise use configuration files.
        /// </summary>
        /// <param name="level"></param>
        public static void SetLoggingLevel(Level level)
        {
            var repositories = LogManager.GetAllRepositories();

            //Configure all loggers to be at the debug level.
            foreach (var repository in repositories)
            {
                repository.Threshold = repository.LevelMap[level.ToString()];
                var hierarchy = (log4net.Repository.Hierarchy.Hierarchy)repository;
                var loggers = hierarchy.GetCurrentLoggers();
                foreach (var logger in loggers)
                {
                    ((log4net.Repository.Hierarchy.Logger)logger).Level = hierarchy.LevelMap[level.ToString()];
                }
            }

            //Configure the root logger.
            var h = (log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepository();
            var rootLogger = h.Root;
            rootLogger.Level = h.LevelMap[level.ToString()];
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:26,代码来源:LogHelper.cs

示例2: RemoveMatchingLogEntries

        public static void RemoveMatchingLogEntries(Level level, string message, string application)
        {
            string commandText = String.Format("DELETE FROM dbo.Log4Net WHERE Level = @Level AND Message = @Message AND Application = @Application");

            using (SqlConnection sqlConnection = new SqlConnection(ConnectionString))
            {
                sqlConnection.Open();
                using (SqlCommand sqlCommand = new SqlCommand(commandText, sqlConnection))
                {
                    sqlCommand.Parameters.Add(new SqlParameter("Level", level.ToString()));
                    sqlCommand.Parameters.Add(new SqlParameter("Message", message));
                    sqlCommand.Parameters.Add(new SqlParameter("Application", application));
                    sqlCommand.ExecuteNonQuery();
                }
            }
        }
开发者ID:JohnDRoach,项目名称:Log4Net.Async,代码行数:16,代码来源:LogsDBAccess.cs

示例3: CountLogEntriesPresent

        public static int CountLogEntriesPresent(Level level, string message, string application)
        {
            string commandText = String.Format("SELECT COUNT(*) FROM dbo.Log4Net (nolock) WHERE Level = @Level AND Message = @Message AND Application = @Application");

            using (SqlConnection sqlConnection = new SqlConnection(ConnectionString))
            {
                sqlConnection.Open();
                using (SqlCommand sqlCommand = new SqlCommand(commandText, sqlConnection))
                {
                    sqlCommand.Parameters.Add(new SqlParameter("Level", level.ToString()));
                    sqlCommand.Parameters.Add(new SqlParameter("Message", message));
                    sqlCommand.Parameters.Add(new SqlParameter("Application", application));
                    int rowCount = (int)sqlCommand.ExecuteScalar();

                    return rowCount;
                }
            }
        }
开发者ID:JohnDRoach,项目名称:Log4Net.Async,代码行数:18,代码来源:LogsDBAccess.cs

示例4: IsLogEntryPresent

        public static bool IsLogEntryPresent(Level level, string message, string application)
        {
            string commandText = String.Format("SELECT * FROM dbo.Log4Net WHERE Level = @Level AND Message = @Message AND Application = @Application");

            using (SqlConnection sqlConnection = new SqlConnection(ConnectionString))
            {
                sqlConnection.Open();
                using (SqlCommand sqlCommand = new SqlCommand(commandText, sqlConnection))
                {
                    sqlCommand.Parameters.Add(new SqlParameter("Level", level.ToString()));
                    sqlCommand.Parameters.Add(new SqlParameter("Message", message));
                    sqlCommand.Parameters.Add(new SqlParameter("Application", application));
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    int fieldCount = 0;
                    while (sqlDataReader.Read())
                    {
                        fieldCount++;
                    }
                    return fieldCount == 1;
                }
            }
        }
开发者ID:JohnDRoach,项目名称:Log4Net.Async,代码行数:22,代码来源:LogsDBAccess.cs

示例5: CreateSelectItem

 private static SelectListItem CreateSelectItem(Level level)
 {
     SelectListItem sel = new SelectListItem();
     sel.Text = level.DisplayName;
     sel.Value = level.ToString();
     return sel;
 }
开发者ID:hesta96,项目名称:DeveloperTools,代码行数:7,代码来源:LoggerSettings.cs

示例6: GetLevelName

 private static string GetLevelName(Level code)
 {
     return string.Format("Log{0}", code.ToString()).ToLower();
 }
开发者ID:Zorbam,项目名称:TaskManager,代码行数:4,代码来源:LogHelper.cs

示例7:

 void ILogger.Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
 {
     tbLog.Text += string.Format("{0} - {1}, {2}", level.ToString(),message.ToString(), exception.ToString());
 }
开发者ID:chuckfrazier,项目名称:DataPlatform,代码行数:4,代码来源:Form1.cs

示例8: LogToFile

		internal static void LogToFile(string logFile, string message, Level level, string category, Exception exception)
		{
			string formatedMessage = null;

			if (exception == null)
			{
				formatedMessage = String.Format("{0} {1,-5} {2,-8} - {3}", new object[]{
										DateTime.Now.ToString("MM-dd HH:mm:ss.fff"),
										level.ToString(),
										category,
										message
									});
			}
			else if (!String.IsNullOrEmpty(message))
			{
				formatedMessage = String.Format("{0} {1,-5} {2,-8} - {3}\r\n{4}", new object[]{
										DateTime.Now.ToString("MM-dd HH:mm:ss.fff"),
										level.ToString(),
										category,
										message,
										exception.ToString()
									});
			}
			else
			{
				formatedMessage = String.Format("{0} {1,-5} {2,-8} - {3}", new object[]{
										DateTime.Now.ToString("MM-dd HH:mm:ss.fff"),
										level.ToString(),
										category,
										exception.ToString()
									});
			}

			try
			{
				int retryCount = 0;
				while (true)
				{
					retryCount++;
					try
					{
						string fileName = AppDomain.CurrentDomain.MapPhysicalPath("logs\\" + logFile);

						if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(fileName)))
						{
							System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fileName));
						}

						using (System.IO.FileStream fs = new System.IO.FileStream(
								GetCurrentLogFile(fileName),
								System.IO.FileMode.Append,
								System.IO.FileAccess.Write, FileShare.Read)
							)
						{
							using (System.IO.StreamWriter w = new System.IO.StreamWriter(fs, Encoding.Default))
							{
								w.WriteLine(formatedMessage);
							}
						}

						break;
					}
					catch
					{
						if (retryCount >= 5)
						{
							throw;
						}
						System.Threading.Thread.Sleep(200);
					}
				}
			}
			catch (Exception err)
			{
				LogToUnhandledExceptions(
					String.Format("{0}\r\n原始要写入的消息为:\r\n{1}", err.GetFriendlyToString(), message)
					);
			}
		}
开发者ID:Kjubo,项目名称:xms.core,代码行数:79,代码来源:LogUtil.cs

示例9: CreateSelectItem

        private static SelectListItem CreateSelectItem(Level level)
        {
            var sel = new SelectListItem
            {
                Text = level.DisplayName,
                Value = level.ToString()
            };

            return sel;
        }
开发者ID:valdisiljuconoks,项目名称:DeveloperTools,代码行数:10,代码来源:LoggerSettings.cs


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