Foxtable(狐表)用户栏目专家坐堂 → web服务端报错处理


  共有3094人关注过本帖平板打印复制链接

主题:web服务端报错处理

帅哥哟,离线,有人找我吗?
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/5/13 16:32:00 [只看该作者]

1.项目事件BeforeShowErrorMessage
Functions.Execute("LogText",e.ex,e.Event)
e.Cancel = True

2.自定义函数logtext

Dim v  = Args(0)
Dim bu As new StringBuilder
bu.AppendLine(Format( Date.Now,"yyyy-MM-dd HH:mm:ss.ffff")) '记录出错时间
If Args.length > 1 Then
    bu.AppendLine("事件/函数: " & Args(1)) '记录出错的事件或者函数
End If
If Typeof v Is Exception Then '如果是Exception的异常类型,则递归获取所有的异常堆栈
    Do While v IsNot Nothing
        bu.AppendLine( v.Message &  vbcrlf & v.StackTrace)
        v = v.InnerException
    Loop
Else '其它情况只能传入错误的文本内容
    bu.AppendLine(v)
End If
Output.Logs("AppLogging").Add(bu.ToString)
Output.Logs("AppLogging").Save(ProjectPath & "Mmsglog.txt",True) '日志位于当前项目目录里
Output.Logs("AppLogging").Clear


 回到顶部