一段log execption 的代码

<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>
阅读更多
个人分类: .net
想对作者说点什么? 我来说一句

这是一段qtp脚本代码

2009年04月22日 23KB 下载

一段防采集的ASP代码

2009年06月11日 3KB 下载

c#的一段邮件邮件发送代码

2009年02月24日 3KB 下载

android 系统日志Logcat 完全捕获

2011年11月08日 4KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭