分享一个收集系统出现错误时收集信息的类
来源:互联网 发布:淘宝比较潮流的男装店 编辑:程序博客网 时间:2024/04/28 14:17
在系统开发过程中,出现错误在所难免,但是怎么样处理好出错的情况,以及尽可能地收集出错时的一些信息,对我们分析错误,从而查找排除错误是很有帮助的,下面提供一个错误信息收集类给大家,希望能够派上用场。
/// <summary>
/// Class that handles gathering of error information
/// for reporting purposes
/// </summary>
public static class ErrorManager
{
#region Public Static Functions
/// <summary>
/// returns information specific to ASP.Net/IIS (Request, Response, Cache, etc.)
/// </summary>
/// <returns>An HTML formatted string containing the ASP.Net information</returns>
public static string GetAllASPNetInformation()
{
StringBuilder Builder = new StringBuilder();
HttpContext Current = HttpContext.Current;
Builder.Append("<strong>Request Variables</strong><br />");
Builder.Append(Current.Request.DumpRequestVariable());
Builder.Append("<br /><br /><strong>Response Variables</strong><br />");
Builder.Append(Current.Response.DumpResponseVariable());
Builder.Append("<br /><br /><strong>Server Variables</strong><br />");
Builder.Append(Current.Request.DumpServerVars());
Builder.Append("<br /><br /><strong>Session Variables</strong><br />");
Builder.Append(Current.Session.DumpSession());
Builder.Append("<br /><br /><strong>Cookie Variables</strong><br />");
Builder.Append(Current.Request.Cookies.DumpCookies());
Builder.Append("<br /><br /><strong>Cache Variables</strong><br />");
Builder.Append(Current.Cache.DumpCache());
Builder.Append("<br /><br /><strong>Application State Variables</strong><br />");
Builder.Append(Current.Application.DumpApplicationState());
return Builder.ToString();
}
/// <summary>
/// Gets assembly information for all currently loaded assemblies
/// </summary>
/// <returns>An HTML formatted string containing the assembly information</returns>
public static string GetAssemblyInformation()
{
StringBuilder Builder = new StringBuilder();
Builder.Append("<strong>Assembly Information</strong><br />");
AppDomain.CurrentDomain.GetAssemblies().ForEach<Assembly>(x => Builder.Append(x.DumpProperties()));
return Builder.ToString();
}
/// <summary>
/// Gets information about the system.
/// </summary>
/// <returns>An HTML formatted string containing the state of the system.</returns>
public static string GetSystemInformation()
{
StringBuilder Builder = new StringBuilder();
Builder.Append("<strong>System Information</strong><br />");
Builder.Append(System.Type.GetType("Utilities.Environment.Environment").DumpProperties());
return Builder.ToString();
}
/// <summary>
/// Gets all process information and outputs it to an HTML formatted string
/// </summary>
/// <returns>An HTML formatted string containing the process information</returns>
public static string GetProcessInformation()
{
StringBuilder Builder = new StringBuilder();
Builder.Append("<strong>Process Information</strong><br />");
Builder.Append(Process.GetProcesses().GetInformation());
return Builder.ToString();
}
#endregion
}
- 分享一个收集系统出现错误时收集信息的类
- sar 收集汇报系统性能的信息
- 一个可以收集竞争对手信息的网站
- 分享的资料收集
- GetLastError错误码信息收集
- 统计信息的收集
- 信息收集渠道:文本分享类网站Paste Site
- linux 收集系统信息 命令
- v$osstat 收集系统信息
- 收集系统信息(hostname、uname)
- oracle收集系统统计信息
- Linux 系统信息收集常用命令
- 【MySQL】关于MySQL错误日志信息的收集
- 自动收集数据库应用系统信息的脚本
- 自动投票系统【一】目标站点的信息收集
- 分享一个收集到的文件和目录操作类FileSystemObject
- 一个收集电脑信息的脚本(vbs)
- 关于设计一个网络信息收集软件的想法
- 从程序员到技术领导者
- CSS基础知识
- apache ab压力测试
- 你会做Web上的用户登录功能吗?
- HDOJ 1862:EXCEL排序 使用一下函数指针数组
- 分享一个收集系统出现错误时收集信息的类
- 一个研究生毕业后的职业规划
- 心经
- Android-- bionic介绍
- 程序员成长的十个阶段
- 局部内部类为什么只能访问final局部变量?
- Set programmatically a custom subclass of UINavigationBar in UINavigationController
- linux 3D桌面compiz
- linux(ubuntu)搭建LAMP