洛阳中航光电项目,为12年项目,此处使用反编译工具恢复源码,恢复为.netframe4.0版本,但仍需使用ie8访问; 数据库使用oracle,现再192.168.8.3服务器,访问账户scott,密码800100

SysLog.cs 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using System.Web.UI;
  5. namespace Common
  6. {
  7. public class SysLog
  8. {
  9. private static Exception EX = null;
  10. private static string Leve = null;
  11. private static string Position = null;
  12. public static void WriteLog(Exception ex)
  13. {
  14. SysLog.EX = ex;
  15. SysLog.WriteDisk();
  16. }
  17. public static void WriteLog(Exception ex, string position)
  18. {
  19. SysLog.EX = ex;
  20. SysLog.Position = position;
  21. SysLog.WriteDisk();
  22. }
  23. public static void WriteLog(Exception ex, string position, string leve)
  24. {
  25. SysLog.EX = ex;
  26. SysLog.Leve = leve;
  27. SysLog.Position = position;
  28. SysLog.WriteDisk();
  29. }
  30. private static void WriteDisk()
  31. {
  32. FileStream fs = null;
  33. try
  34. {
  35. string str = "时间:" + DateTime.Now.ToString();
  36. if (SysLog.EX != null)
  37. {
  38. str = "错误消息:" + SysLog.EX.Message + "\t";
  39. if (SysLog.EX.HelpLink != null)
  40. {
  41. str = str + "与此关联的文件:" + SysLog.EX.HelpLink + "\t";
  42. }
  43. str = str + "错误消息字符串表示:" + SysLog.EX.StackTrace + "\t";
  44. }
  45. if (SysLog.Position != null)
  46. {
  47. str = str + "错误位置:" + SysLog.Position + "\t";
  48. }
  49. if (SysLog.Leve != null)
  50. {
  51. str = str + "错误级别:" + SysLog.Leve + "\t";
  52. }
  53. Page pag = new Page();
  54. str += "\r\n\r\n";
  55. string path = pag.Server.MapPath("/") + "\\Log\\" + DateTime.Now.ToShortDateString() + "Log.log";
  56. if (!File.Exists(path))
  57. {
  58. Directory.CreateDirectory(pag.Server.MapPath("/") + "\\Log");
  59. File.Create(path).Close();
  60. }
  61. byte[] bytData = Encoding.Default.GetBytes(str);
  62. fs = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.ReadWrite, 2048);
  63. fs.Write(bytData, 0, bytData.Length);
  64. }
  65. finally
  66. {
  67. if (fs != null)
  68. {
  69. fs.Close();
  70. }
  71. SysLog.EX = null;
  72. SysLog.Position = null;
  73. SysLog.Leve = null;
  74. }
  75. }
  76. }
  77. }