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

C# Logging类代码示例

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

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



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

示例1: UpdateGrid

        public ActionResult UpdateGrid(string hiddenSchoolFilter, string hiddenSchoolYearFilter)
        {
            try
            {
                dbTIREntities db = new dbTIREntities();
                SiteUser siteUser = ((SiteUser)Session["SiteUser"]);
                StudentService studentService = new StudentService(siteUser, db);
                SchoolService schoolService = new SchoolService(siteUser, db);
                ModelServices modelService = new ModelServices();
                ViewBag.DistrictDesc = siteUser.Districts[0].Name;
                int schoolYearId = modelService.GetSchoolYearId(Convert.ToInt32(hiddenSchoolYearFilter));
                ViewBag.SchoolId = modelService.DropDownDataSchool(hiddenSchoolFilter, siteUser.EdsUserId, schoolYearId, true);
                ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT");
                ViewBag.SchoolYearList = schoolService.DropDownDataSchoolYear(hiddenSchoolYearFilter);

                ViewBag.SchoolYear = hiddenSchoolYearFilter;

                return View("Index", new SiteModels()
                {
                    Students = studentService.GetViewData(hiddenSchoolYearFilter, hiddenSchoolFilter)
                });
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
开发者ID:ezimaxtechnologies,项目名称:ASP.NetMVC,代码行数:29,代码来源:StudentsController.cs


示例2: MetadataUtils

 public MetadataUtils(Config.Saml2Configuration configuration, Logging.IInternalLogger logger)
 {
     if (configuration == null) throw new ArgumentNullException("configuration");
     if (logger == null) throw new ArgumentNullException("logger");
     this.configuration = configuration;
     this.logger = logger;
 }
开发者ID:jbparker,项目名称:SAML2,代码行数:7,代码来源:MetadataUtils.cs


示例3: Log

 /// <summary>
 /// Logs the information at the provided level.
 /// </summary>
 /// <param name="level">The logging level.</param>
 /// <param name="messageFormat">The message format.</param>
 /// <param name="args">The arguments.</param>
 public void Log(Logging.LogLevel level, string messageFormat, params object[] args)
 {
     switch (level)
     {
         case Logging.LogLevel.Fatal:
             this.logger.Fatal(messageFormat, args);
             break;
         case Logging.LogLevel.Error:
             this.logger.Error(messageFormat, args);
             break;
         case Logging.LogLevel.Warning:
             this.logger.Warn(messageFormat, args);
             break;
         case Logging.LogLevel.Info:
             this.logger.Info(messageFormat, args);
             break;
         case Logging.LogLevel.Debug:
             this.logger.Debug(messageFormat, args);
             break;
         case Logging.LogLevel.Trace:
             this.logger.Trace(messageFormat, args);
             break;
         default:
             this.logger.Trace(messageFormat, args);
             break;
     }
 }
开发者ID:movileanubeniamin,项目名称:kephas,代码行数:33,代码来源:InternalLogger.cs


示例4: Validation

        public Validation()
        {
            _tfsServer = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(ConfigurationManager.AppSettings["TfsServer"]));
            _vsoServer = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(ConfigurationManager.AppSettings["VsoServer"]));
            _vsoStore = _vsoServer.GetService<WorkItemStore>();
            _tfsStore = _tfsServer.GetService<WorkItemStore>();

            var actionValue = ConfigurationManager.AppSettings["Action"];
            if (actionValue.Equals("validate", StringComparison.OrdinalIgnoreCase))
            {
                _action = Action.Validate;
            }
            else
            {
                _action = Action.Compare;
            }

            var runDateTime = DateTime.Now.ToString("yyyy-MM-dd-HHmmss");

            var dataFilePath = ConfigurationManager.AppSettings["DataFilePath"];
            var dataDir = string.IsNullOrWhiteSpace(dataFilePath) ? Directory.GetCurrentDirectory() : dataFilePath;
            var dirName = string.Format("{0}\\Log-{1}",dataDir,runDateTime);

            if (!Directory.Exists(dirName))
            {
                Directory.CreateDirectory(dirName);
            }

            _errorLog = new Logging(string.Format("{0}\\Error.txt", dirName));
            _statusLog = new Logging(string.Format("{0}\\Status.txt", dirName));
            _fullLog = new Logging(string.Format("{0}\\FullLog.txt", dirName));

            _taskList = new List<Task>();

            if (!_action.Equals(Action.Compare))
            {
                return;
            }

            _valFieldErrorLog = new Logging(string.Format("{0}\\FieldError.txt", dirName));
            _valTagErrorLog = new Logging(string.Format("{0}\\TagError.txt", dirName));
            _valPostMigrationUpdateLog = new Logging(string.Format("{0}\\PostMigrationUpdate.txt", dirName));

            _imageLog = new Logging(string.Format("{0}\\ItemsWithImage.txt", dirName));

            _commonFields = new List<string>();
            _itemTypesToValidate = new List<string>();

            var fields = ConfigurationManager.AppSettings["CommonFields"].Split(',');
            foreach (var field in fields)
            {
                _commonFields.Add(field);
            }

            var types = ConfigurationManager.AppSettings["WorkItemTypes"].Split(',');
            foreach (var type in types)
            {
                _itemTypesToValidate.Add(type);
            }
        }
开发者ID:hshishir,项目名称:ValidationTool,代码行数:60,代码来源:Validation.cs


示例5: ViewMatchSessions

 public ViewMatchSessions(
     Logging.LoggingInterfaces.ITracer logger)
 {
     this.logger = logger;
     this.context = FSharpInterop.Interop.GetNewContext();
     InitializeComponent();
 }
开发者ID:matthid,项目名称:Yaaf.GameMediaManager,代码行数:7,代码来源:ViewMatchSessions.cs


示例6: Log

        /// <summary>
        /// Logs the information at the provided level.
        /// </summary>
        /// <param name="level">        The logging level.</param>
        /// <param name="exception">    The exception.</param>
        /// <param name="messageFormat">The message format.</param>
        /// <param name="args">         A variable-length parameters list containing arguments.</param>
        public void Log(Logging.LogLevel level, Exception exception, string messageFormat, params object[] args)
        {
            if (exception == null)
            {
                this.Log(level, messageFormat, args);
                return;
            }

            switch (level)
            {
                case Logging.LogLevel.Fatal:
                    this.logger.Fatal(exception, messageFormat, args);
                    break;
                case Logging.LogLevel.Error:
                    this.logger.Error(exception, messageFormat, args);
                    break;
                case Logging.LogLevel.Warning:
                    this.logger.Warn(exception, messageFormat, args);
                    break;
                case Logging.LogLevel.Info:
                    this.logger.Info(exception, messageFormat, args);
                    break;
                case Logging.LogLevel.Debug:
                    this.logger.Debug(exception, messageFormat, args);
                    break;
                case Logging.LogLevel.Trace:
                    this.logger.Trace(exception, messageFormat, args);
                    break;
                default:
                    this.logger.Trace(exception, messageFormat, args);
                    break;
            }
        }
开发者ID:raimu,项目名称:kephas,代码行数:40,代码来源:NLogger.cs


示例7: Index

        // GET: /Students/
        public ActionResult Index()
        {
            try
            {
                dbTIREntities db = new dbTIREntities();
                SiteUser siteUser = ((SiteUser)Session["SiteUser"]);
                StudentService studentService = new StudentService(siteUser, db);
                SchoolService schoolService = new SchoolService(siteUser, db);
                ModelServices modelService = new ModelServices();
                string currentSchoolYear = schoolService.GetCurrentSchoolYear();
                ViewBag.DistrictDesc = siteUser.Districts[0].Name;
                int schoolYearId = modelService.SchoolYearId();
                ViewBag.SchoolId = modelService.DropDownDataSchool("", siteUser.EdsUserId, schoolYearId, true);
                ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT");
                //ViewBag.SchoolYear = HelperService.SchoolYearDescription(db);
                ViewBag.SchoolYearList = schoolService.DropDownDataSchoolYear(currentSchoolYear);
                ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT");
                ViewBag.SchoolYear = currentSchoolYear;

                return View(new SiteModels()
                {
                    Students = studentService.GetViewData(currentSchoolYear, "", "")
                });
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
开发者ID:ezimaxtechnologies,项目名称:ASP.NetMVC,代码行数:32,代码来源:StudentsController.cs


示例8: SharedObjects

 static SharedObjects()
 {
     ProgramName = string.Empty;
     MainWin = (Form)null;
     ProgramExit = false;
     Log = new Logging();
 }
开发者ID:x893,项目名称:BTool,代码行数:7,代码来源:SharedObjects.cs


示例9: Logging_LogMessage

        void Logging_LogMessage(object sender, Logging.LogMessageEventArgs e)
        {
            CWSRestart.Controls.LogFilter.MessageType t = Controls.LogFilter.MessageType.General;

            switch (e.type)
            {
                case Logging.MessageType.Error:
                    t = Controls.LogFilter.MessageType.Error;
                    break;

                case Logging.MessageType.Info:
                    t = Controls.LogFilter.MessageType.Info;
                    break;

                case Logging.MessageType.Server:
                    t = Controls.LogFilter.MessageType.Server;
                    break;

                case Logging.MessageType.Warning:
                    t = Controls.LogFilter.MessageType.Warning;
                    break;
            }

            Application.Current.Dispatcher.BeginInvoke(new Action<Controls.LogFilter.LogMessage>((m) => LogControl.Messages.Add(m)), new Controls.LogFilter.LogMessage(e.message, t)); 
        }
开发者ID:GuardMoony,项目名称:CWSRestart,代码行数:25,代码来源:FrontEnd.xaml.cs


示例10: EmailerService

        public EmailerService(Logging.ILogger logger
			, Services.IConnectorService connectorService
			, Services.IAccountService accountService
			, Services.CryptoService cryptoService
			, Services.IScheduledTaskService taskService
			)
        {
            this.Logger = logger;
            this.ConnectorService = connectorService;
            this.CryptoService = cryptoService;
            this.AccountService = accountService;
            this.TaskService = taskService;

            var smtpSection = System.Configuration.ConfigurationManager.GetSection("system.net/mailSettings/smtp") as System.Net.Configuration.SmtpSection;
            if (!smtpSection.From.IsNullOrTrimmedEmpty())
            {
                m_MailFrom = new MailAddress(smtpSection.From);
            }
            else
            {
                m_MailFrom = new MailAddress(ERPStoreApplication.WebSiteSettings.Contact.EmailSender,
                               ERPStoreApplication.WebSiteSettings.Contact.EmailSenderName);
            }

            var bccEmail = ERPStoreApplication.WebSiteSettings.Contact.BCCEmail ?? ERPStoreApplication.WebSiteSettings.Contact.ContactEmail;
            m_Bcc = new MailAddressCollection();
            if (bccEmail != null)
            {
                var emailList = bccEmail.Split(';');
                foreach (var email in emailList)
                {
                    m_Bcc.Add(email.Trim());
                }
            }
        }
开发者ID:hhariri,项目名称:ReSharper8Demo,代码行数:35,代码来源:EmailerService.cs


示例11: FetchMatchdataDialog

 public FetchMatchdataDialog(Logging.LoggingInterfaces.ITracer logger, string defaultLink)
 {
     this.logger = logger;
     Result = null;
     InitializeComponent();
     linkTextBox.Text = defaultLink;
 }
开发者ID:matthid,项目名称:Yaaf.GameMediaManager,代码行数:7,代码来源:FetchMatchdataDialog.cs


示例12: IsEnabled

        /// <summary>
        /// Indicates whether logging at the indicated level is enabled.
        /// </summary>
        /// <param name="level">The logging level.</param>
        /// <returns>
        /// <c>true</c> if enabled, <c>false</c> if not.
        /// </returns>
        public bool IsEnabled(Logging.LogLevel level)
        {
            if (this.logger.IsTraceEnabled)
            {
                return level <= Logging.LogLevel.Trace;
            }

            if (this.logger.IsDebugEnabled)
            {
                return level <= Logging.LogLevel.Debug;
            }

            if (this.logger.IsInfoEnabled)
            {
                return level <= Logging.LogLevel.Info;
            }

            if (this.logger.IsWarnEnabled)
            {
                return level <= Logging.LogLevel.Warning;
            }

            if (this.logger.IsErrorEnabled)
            {
                return level <= Logging.LogLevel.Error;
            }

            if (this.logger.IsFatalEnabled)
            {
                return level <= Logging.LogLevel.Fatal;
            }

            return false;
        }
开发者ID:raimu,项目名称:kephas,代码行数:41,代码来源:NLogger.cs


示例13: HttpContextCartRepository

        public HttpContextCartRepository(System.Web.HttpContext ctx
			, Services.ICacheService cacheService
			, Logging.ILogger logger)
        {
            HttpContext = ctx;
            CacheService = cacheService;
            this.Logger = logger;
        }
开发者ID:hhariri,项目名称:ReSharper8Demo,代码行数:8,代码来源:HttpContextCartRepository.cs


示例14: SettingsService

        public SettingsService(ERPStore.Services.ICacheService cacheService
			, Logging.ILogger logger
			, Microsoft.Practices.Unity.IUnityContainer container)
        {
            this.CacheService = cacheService;
            this.Logger = logger;
            this.Container = container;
        }
开发者ID:hhariri,项目名称:ReSharper8Demo,代码行数:8,代码来源:SettingsService.cs


示例15: When_config_section_threshold_is_null_threshold_should_be_null

 public void When_config_section_threshold_is_null_threshold_should_be_null()
 {
     var configSection = new Logging
     {
         Threshold = null
     };
     Assert.IsNull(SetLoggingLibrary.GetThresholdFromConfigSection(configSection));
 }
开发者ID:89sos98,项目名称:NServiceBus,代码行数:8,代码来源:SetLoggingLibraryTests.cs


示例16: When_config_section_threshold_is_validString_threshold_should_be_that_value

 public void When_config_section_threshold_is_validString_threshold_should_be_that_value()
 {
     var configSection = new Logging
     {
         Threshold = "High"
     };
     Assert.AreEqual("High", SetLoggingLibrary.GetThresholdFromConfigSection(configSection));
 }
开发者ID:89sos98,项目名称:NServiceBus,代码行数:8,代码来源:SetLoggingLibraryTests.cs


示例17: logSentence

 public void logSentence()
 {
     if (_wholeSentence.Length > 0)
     {
         var logging = new Logging();
         logging.log("sentences", _wholeSentence);
     }
 }
开发者ID:ApexHAB,项目名称:apex-lumia,代码行数:8,代码来源:Sentence.cs


示例18: Employee

 /// <summary>
 /// Constructor that takes in firstName and lastName as parameters.
 /// Intializes all other attributes to their default values.
 /// </summary>
 /// <param name="firstName">Value for firstName. String.</param>
 /// <param name="lastName">Value for lastName. String.</param>
 public Employee(String firstName, String lastName)
 {
     logfile = new Logging();
     SetFirstName("");
     SetLastName("");
     SetSocialNumber("000000000");
     SetDateOfBirth(new DateTime(0));
 }
开发者ID:WilliamPring,项目名称:SET,代码行数:14,代码来源:Employee.cs


示例19: ManagePlayers

        public ManagePlayers(Logging.LoggingInterfaces.ITracer logger)
        {
            this.logger = logger;

            // this is a copy.. this way we can discard everything at the end, if we need to
            wrapper = FSharpInterop.Interop.GetNewContext();
            InitializeComponent();
        }
开发者ID:matthid,项目名称:Yaaf.GameMediaManager,代码行数:8,代码来源:ManagePlayers.cs


示例20: logText

        /// <summary>
        /// Logs text to the textbox on the main form.
        /// </summary>
        /// <param name="Text">The text to log.</param>
        /// <param name="Type">A Logging.logType enum value, indicating the log's type.</param>
        public void logText(string Text, Logging.logType Type)
        {
            if (this.InvokeRequired)
                this.BeginInvoke(_Logger, Text, Type);
            else
            {
                try
                {
                    lock (this.txtLog)
                    {
                        switch (Type)
                        {
                            case Logging.logType.commonWarning:
                                {
                                    StringBuilder Data = new StringBuilder();
                                    Data.Append("Warning!" + Environment.NewLine);
                                    Data.Append("Time: " + DateTime.Now.ToShortTimeString() + Environment.NewLine);
                                    Data.Append("Description: " + Text + Environment.NewLine + Environment.NewLine);

                                    this.txtLog.SelectionColor = Color.Brown;
                                    this.txtLog.SelectedText = Data.ToString();
                                }
                                break;

                            case Logging.logType.reactorError:
                            case Logging.logType.commonError:
                                {
                                    StackFrame st = new StackTrace().GetFrame(2);
                                    StringBuilder Data = new StringBuilder();

                                    Data.Append("ERROR!" + Environment.NewLine);
                                    Data.Append("Time: " + DateTime.Now.ToShortTimeString() + Environment.NewLine);
                                    Data.Append("Object: " + st.GetMethod().ReflectedType.Name + Environment.NewLine);
                                    Data.Append("Method: " + st.GetMethod().Name + Environment.NewLine);
                                    Data.Append("Description: " + Text + Environment.NewLine + Environment.NewLine);

                                    this.txtLog.SelectionColor = Color.DarkRed;
                                    this.txtLog.SelectedText = Data.ToString();
                                }
                                break;

                            default:
                                {
                                    this.txtLog.AppendText("# ");
                                    this.txtLog.AppendText(Text);
                                    this.txtLog.AppendText(Environment.NewLine);
                                }
                                break;
                        }

                        this.txtLog.SelectionStart = this.txtLog.Text.Length;
                        this.txtLog.ScrollToCaret();
                        this.txtLog.Refresh();
                    }
                }
                catch (Exception) { }
            }
        }
开发者ID:habb0,项目名称:Woodpecker,代码行数:63,代码来源:mainForm.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# LoggingEvent类代码示例发布时间:2022-05-24
下一篇:
C# LoggerVerbosity类代码示例发布时间: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