Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在企业日志c中对日志进行分类#_C#_Asp.net_Enterprise Library - Fatal编程技术网

C# 在企业日志c中对日志进行分类#

C# 在企业日志c中对日志进行分类#,c#,asp.net,enterprise-library,C#,Asp.net,Enterprise Library,在我的应用程序中,我将异常和警告记录到日志文件中。现在我想将这些异常和警告记录到类别中。应该有四种对应于临界、错误、警告、信息等的方法。我如何做到这一点 LogInfo=Logger.LogInformation(1,DateTime.Now,例如Message,string.Empty,parameterHashTable[“FileName”].ToString()); 我通常使用System.Diagnostics.EventLogEntryType进行此操作。它提供以下枚举: Eve

在我的应用程序中,我将异常和警告记录到日志文件中。现在我想将这些异常和警告记录到类别中。应该有四种对应于临界、错误、警告、信息等的方法。我如何做到这一点


LogInfo=Logger.LogInformation(1,DateTime.Now,例如Message,string.Empty,parameterHashTable[“FileName”].ToString());

我通常使用System.Diagnostics.EventLogEntryType进行此操作。它提供以下枚举:

EventLogEntryType.Error;
EventLogEntryType.FailureAudit;
EventLogEntryType.Information;
EventLogEntryType.SuccessAudit;
EventLogEntryType.Warning;

这种登录信息方法来自哪里?我不相信Logger类上的方法是企业库的一部分。通常您会调用Logger。使用LogEntry写入。在LogEntry上设置严重性。此外,如果要记录异常,可能需要研究使用异常处理应用程序块。然后,您不必手工编写日志条目,您可以在日志中获得有关异常的更多有用信息,例如堆栈跟踪。