一段log execption 的代码
来源:互联网 发布:shadow defender 知乎 编辑:程序博客网 时间:2024/05/18 19:21
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
try {
string fileName = Path.Combine( Application.StartupPath, "error.log" );
StreamWriter sw = new StreamWriter( fileName, true );
sw.WriteLine( "Errorlog.WriteExceptionlog() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" );
try {
DateTime now = DateTime.Now;
sw.WriteLine( "CurrentDate: " + now.ToLongDateString() );
sw.WriteLine( "CurrentTime: " + now.ToLongTimeString() );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-CurrentDateTime>" + ex.ToString() );
}
try {
sw.WriteLine( "Exception.Type: " + e.GetType().Name );
sw.WriteLine( "Exception.Message: " + e.Message );
sw.WriteLine( "Exception.Source: " + e.Source );
sw.WriteLine( "Exception.HelpLink: " + e.HelpLink );
sw.WriteLine( "Exception.TargetSite: " + e.TargetSite );
sw.WriteLine( "Exception.StackTrace: " );
sw.WriteLine( e.StackTrace );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-Exception>" + ex.ToString() );
}
try {
sw.WriteLine( "GC.TotalMemory: " + GC.GetTotalMemory( false ) );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-GC>" + ex.ToString() );
}
try {
sw.WriteLine( "Application.ProductName: " + Application.ProductName );
sw.WriteLine( "Application.ProductVersion: " + Application.ProductVersion );
sw.WriteLine( "Application.StartupPath: " + Application.StartupPath );
sw.WriteLine( "Application.ExecutablePath: " + Application.ExecutablePath );
sw.WriteLine( "Application.CurrentDirectory: " + Directory.GetCurrentDirectory() );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-Application>" + ex.ToString() );
}
try {
Assembly execAssembly = Assembly.GetExecutingAssembly();
sw.WriteLine( "ExecutingAssembly.CodeBase: " + execAssembly.CodeBase );
sw.WriteLine( "ExecutingAssembly.Location: " + execAssembly.Location );
sw.WriteLine( "ExecutingAssembly.GlobalAssemblyCache: " + execAssembly.GlobalAssemblyCache );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-ExecutingAssembly>" + ex.ToString() );
}
try {
foreach( string watchName in s_htWatches.Keys ) {
sw.WriteLine( "Watch[" + watchName + "]: " + GetWatchString( watchName ) );
}
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-Watches>" + ex.ToString() );
}
try {
foreach( logEntry logEntry in s_logEntries ) {
sw.WriteLine( "logEntry" + logEntry.ToString() );
}
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-logEntry>" + ex.ToString() );
}
try {
Assembly selfAssembly = Assembly.GetAssembly( typeof( BugTracking ) );
sw.WriteLine( "CurrentAssembly.CodeBase: " + selfAssembly.CodeBase );
sw.WriteLine( "CurrentAssembly.Location: " + selfAssembly.Location );
sw.WriteLine( "CurrentAssembly.GlobalAssemblyCache: " + selfAssembly.GlobalAssemblyCache );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-CurrentAssembly>" + ex.ToString() );
}
try {
Thread thread = Thread.CurrentThread;
sw.WriteLine( "CurrentThread.Name: " + thread.Name );
sw.WriteLine( "CurrentThread.Priority: " + thread.Priority );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-CurrentThread>" + ex.ToString() );
}
try {
Process process = Process.GetCurrentProcess();
sw.WriteLine( "CurrentProcess.Name: " + process.ProcessName );
sw.WriteLine( "CurrentProcess.MachineName: " + process.MachineName );
sw.WriteLine( "CurrentProcess.MainModule: " + process.MainModule );
sw.WriteLine( "CurrentProcess.StartDate: " + process.StartTime.ToLongDateString() );
sw.WriteLine( "CurrentProcess.StartTime: " + process.StartTime.ToLongTimeString() );
sw.WriteLine( "CurrentProcess.UserProcessorTime: " + process.UserProcessorTime );
sw.WriteLine( "CurrentProcess.TotalProcessorTime: " + process.TotalProcessorTime );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-CurrentProcess>" + ex.ToString() );
}
try {
OperatingSystem os = Environment.OSVersion;
sw.WriteLine( "Environment.OSVersion.Platform: " + os.Platform );
sw.WriteLine( "Environment.OSVersion.Version: " + os.Version );
Version ver = Environment.Version;
sw.WriteLine( "Environment.Version.Major: " + ver.Major );
sw.WriteLine( "Environment.Version.Minor: " + ver.Minor );
sw.WriteLine( "Environment.Version.Revision: " + ver.Revision );
sw.WriteLine( "Environment.Version.Build: " + ver.Build );
sw.WriteLine( "Environment.UserName: " + Environment.UserName );
sw.WriteLine( "Environment.SystemDirectory: " + Environment.SystemDirectory );
sw.WriteLine( "Environment.TickCount: " + Environment.TickCount );
sw.WriteLine( "Environment.CommandLine: " + Environment.CommandLine );
sw.WriteLine( "Environment.WorkingSet: " + Environment.WorkingSet );
string[] args = Environment.GetCommandLineArgs();
if( args != null ) {
for( int i = 0; i < args.Length; i ++ ) {
sw.WriteLine( "Environment.CommandLineArgs[" + i + "]: " + args[i] );
}
}
sw.WriteLine( "Environment.StackTrace: " );
sw.WriteLine( Environment.StackTrace );
sw.Flush();共2页: 上一页 1 [2] 下一页 <script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
static public string WriteExceptionRecord( Exception e ) {try {
string fileName = Path.Combine( Application.StartupPath, "error.log" );
StreamWriter sw = new StreamWriter( fileName, true );
sw.WriteLine( "Errorlog.WriteExceptionlog() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" );
try {
DateTime now = DateTime.Now;
sw.WriteLine( "CurrentDate: " + now.ToLongDateString() );
sw.WriteLine( "CurrentTime: " + now.ToLongTimeString() );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-CurrentDateTime>" + ex.ToString() );
}
try {
sw.WriteLine( "Exception.Type: " + e.GetType().Name );
sw.WriteLine( "Exception.Message: " + e.Message );
sw.WriteLine( "Exception.Source: " + e.Source );
sw.WriteLine( "Exception.HelpLink: " + e.HelpLink );
sw.WriteLine( "Exception.TargetSite: " + e.TargetSite );
sw.WriteLine( "Exception.StackTrace: " );
sw.WriteLine( e.StackTrace );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-Exception>" + ex.ToString() );
}
try {
sw.WriteLine( "GC.TotalMemory: " + GC.GetTotalMemory( false ) );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-GC>" + ex.ToString() );
}
try {
sw.WriteLine( "Application.ProductName: " + Application.ProductName );
sw.WriteLine( "Application.ProductVersion: " + Application.ProductVersion );
sw.WriteLine( "Application.StartupPath: " + Application.StartupPath );
sw.WriteLine( "Application.ExecutablePath: " + Application.ExecutablePath );
sw.WriteLine( "Application.CurrentDirectory: " + Directory.GetCurrentDirectory() );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-Application>" + ex.ToString() );
}
try {
Assembly execAssembly = Assembly.GetExecutingAssembly();
sw.WriteLine( "ExecutingAssembly.CodeBase: " + execAssembly.CodeBase );
sw.WriteLine( "ExecutingAssembly.Location: " + execAssembly.Location );
sw.WriteLine( "ExecutingAssembly.GlobalAssemblyCache: " + execAssembly.GlobalAssemblyCache );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-ExecutingAssembly>" + ex.ToString() );
}
try {
foreach( string watchName in s_htWatches.Keys ) {
sw.WriteLine( "Watch[" + watchName + "]: " + GetWatchString( watchName ) );
}
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-Watches>" + ex.ToString() );
}
try {
foreach( logEntry logEntry in s_logEntries ) {
sw.WriteLine( "logEntry" + logEntry.ToString() );
}
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-logEntry>" + ex.ToString() );
}
try {
Assembly selfAssembly = Assembly.GetAssembly( typeof( BugTracking ) );
sw.WriteLine( "CurrentAssembly.CodeBase: " + selfAssembly.CodeBase );
sw.WriteLine( "CurrentAssembly.Location: " + selfAssembly.Location );
sw.WriteLine( "CurrentAssembly.GlobalAssemblyCache: " + selfAssembly.GlobalAssemblyCache );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-CurrentAssembly>" + ex.ToString() );
}
try {
Thread thread = Thread.CurrentThread;
sw.WriteLine( "CurrentThread.Name: " + thread.Name );
sw.WriteLine( "CurrentThread.Priority: " + thread.Priority );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-CurrentThread>" + ex.ToString() );
}
try {
Process process = Process.GetCurrentProcess();
sw.WriteLine( "CurrentProcess.Name: " + process.ProcessName );
sw.WriteLine( "CurrentProcess.MachineName: " + process.MachineName );
sw.WriteLine( "CurrentProcess.MainModule: " + process.MainModule );
sw.WriteLine( "CurrentProcess.StartDate: " + process.StartTime.ToLongDateString() );
sw.WriteLine( "CurrentProcess.StartTime: " + process.StartTime.ToLongTimeString() );
sw.WriteLine( "CurrentProcess.UserProcessorTime: " + process.UserProcessorTime );
sw.WriteLine( "CurrentProcess.TotalProcessorTime: " + process.TotalProcessorTime );
sw.Flush();
}
catch( Exception ex ) {
sw.WriteLine( "<error-CurrentProcess>" + ex.ToString() );
}
try {
OperatingSystem os = Environment.OSVersion;
sw.WriteLine( "Environment.OSVersion.Platform: " + os.Platform );
sw.WriteLine( "Environment.OSVersion.Version: " + os.Version );
Version ver = Environment.Version;
sw.WriteLine( "Environment.Version.Major: " + ver.Major );
sw.WriteLine( "Environment.Version.Minor: " + ver.Minor );
sw.WriteLine( "Environment.Version.Revision: " + ver.Revision );
sw.WriteLine( "Environment.Version.Build: " + ver.Build );
sw.WriteLine( "Environment.UserName: " + Environment.UserName );
sw.WriteLine( "Environment.SystemDirectory: " + Environment.SystemDirectory );
sw.WriteLine( "Environment.TickCount: " + Environment.TickCount );
sw.WriteLine( "Environment.CommandLine: " + Environment.CommandLine );
sw.WriteLine( "Environment.WorkingSet: " + Environment.WorkingSet );
string[] args = Environment.GetCommandLineArgs();
if( args != null ) {
for( int i = 0; i < args.Length; i ++ ) {
sw.WriteLine( "Environment.CommandLineArgs[" + i + "]: " + args[i] );
}
}
sw.WriteLine( "Environment.StackTrace: " );
sw.WriteLine( Environment.StackTrace );
sw.Flush();共2页: 上一页 1 [2] 下一页 <script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 一段log execption 的代码
- execption
- Execption
- 一段Unicode下的Log
- Error和Execption的区别
- 一段不可思议的代码
- 一段写晕掉的代码
- 一段好玩的代码
- 一段有趣的代码
- 一段漏洞百出的代码
- 一段弃暗投明的代码
- treeview的一段代码
- 一段分页的代码
- 一段简单的代码
- 一段smc的代码
- 一段好的代码
- CRM_ORDER_READ 的一段代码
- 一段ITEMCHANGED的代码
- Oracle 10g for Windows 32bit安装图解
- [c#]:如何在C#中读写INI文件(四)
- T-SQL 生成一个简易的 公历年历 T-SQL 含日期所在月及
- 从App到Application (CSDN)
- 手工转移数据库Step By Step
- 一段log execption 的代码
- 伟大的解决方案—DataWindow.Net(一)
- 大数据量下的分页
- 如何在Windows 2000环境中Kill掉单个Oracle线程
- 使用C#拷贝String到struct
- SQL SERVER 2000系统提供的跟踪函数(一)
- Visual Basic .NET中的异常处理简介(上)
- SQL SERVER 2000系统提供的跟踪函数(二)
- beta2中的SqlConnection和SqlCommand