Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp classic 经典asp中的异步日志记录_Asp Classic - Fatal编程技术网

Asp classic 经典asp中的异步日志记录

Asp classic 经典asp中的异步日志记录,asp-classic,Asp Classic,对于部署在IIS6.0中的经典asp应用程序,我需要异步将错误记录到文本文件中,以便日志记录将应用程序与日志记录资源分离,从而允许应用程序在底层日志记录基础结构因任何原因变得不可用时继续运行。我在其中一个回复中看到了xmlhttp可以使用的类似问题。还有别的办法吗?请帮助您想记录哪些错误 ASP错误?然后,您必须运行所有带有ON ERROR RESUME NEXT的代码,并在每个站点上编写一个错误处理程序。例如,您可以通过SSI包含在所有页面上 由于经典的asp是单元线程模型,所以您不能真正异步

对于部署在IIS6.0中的经典asp应用程序,我需要异步将错误记录到文本文件中,以便日志记录将应用程序与日志记录资源分离,从而允许应用程序在底层日志记录基础结构因任何原因变得不可用时继续运行。我在其中一个回复中看到了xmlhttp可以使用的类似问题。还有别的办法吗?请帮助

您想记录哪些错误

ASP错误?然后,您必须运行所有带有ON ERROR RESUME NEXT的代码,并在每个站点上编写一个错误处理程序。例如,您可以通过SSI包含在所有页面上

由于经典的asp是单元线程模型,所以您不能真正异步执行此操作!但是您可以编写COM+组件。这个组件有一个方法,您可以在其中通过val传递err.number、description、source(+可能是Request.ServerVariables(“URL”))然后快速返回。在组件内部,您可以启动异步线程来写入日志文件或向任何数据库写入错误


不知道这是否是你想要的,但如果是这样,那就是你可以做的方式。

不完全是你所要求的,但是这里有一个ASP经典的Chrome日志解决方案,它提供了一个与javascript console.log()等相当一致的体验。。。 日志将JS注入响应并登录到开发人员控制台(F12) 单元测试和样本使用-内部 注意事项:避免出现“脚本内脚本”的情况

<%

' log from ASP lines to chrome dev console - using the same javascript syntax
' ref: https://developers.google.com/web/tools/chrome-devtools/console/api#dir

' to add this to your asp page:
' <!--#Include file ="log.asp"-->

' sample usage - see unit test at bottom

' to turn logging ON, you have those options:
'  console.active = true
'  run on localhost
'  add queryString log=1  (e.g. www.myweb.com?log=1)


class oConsole
    private isActive
    private oGroup
    private mGroupLabel
    private mGroupType
    Private Sub Class_Initialize(  )
        isActive = (Request.ServerVariables("SERVER_NAME") = "localhost") or _
                   (request.queryString("log") = "1") or _
                   session("log")
        set oGroup = nothing
    end sub

    Public Property Let active(a)
        isActive = a
        session("log") = cBool(a)
    End Property

    public property get active
      active = isActive
    end property

    private sub script(func, text)
        if not isActive then exit sub
        text = replace(text, """", "\""")
        if not oGroup is nothing then
            oGroup.add oGroup.count, func & "(""" & text & """)"
        else
            Response.Write "<script language=javascript>console." & func & "(""" & text & """)</script>" & vbCrLf
        end if
    end sub

    public sub log(Text)
        script "log", Text
    end sub

    public sub Warn(w)
        script "warn", w
    end sub

    public sub error(e)
        if e = "" then e = "Error 0x" & hex(err.number) & " " & err.description
        script "error", e
    end sub

    public sub assert(cond, message)
        if not cond then script "assert", """,""" & message
    end sub

    public sub logVar(Variable)
        log Variable & "=" & eval(Variable) 
    end sub

    public sub clear
        if not isActive then exit sub
        response.write "<script language=javascript>console.clear()</script>"  & vbCrLf
    end sub

    public sub group(label)
        set oGroup = CreateObject("Scripting.Dictionary")
        mGroupLabel = label
        mGroupType = "group"
    end sub

    public sub groupCollapsed(label)
        group label
        mGroupType = "groupCollapsed"
    end sub

    public sub groupEnd
        if isNull(oGroup) then exit sub
        Response.Write "<script language=javascript>" & vbCrLf
        response.write "console." & mGroupType & "(""" & mGroupLabel & """)" & vbCrLf
        dim X
        for each X in oGroup
            response.write "console." & oGroup.item(X) & vbCrLf 
        next
        response.write "console.groupEnd()" & vbCrLf
        response.write "</script>" & vbCrLf
        set oGroup = nothing
    end sub

end class

dim console
set console = new oConsole


sub logTest
    if not console.active then
      console.active = true
      console.clear 
      console.warn "logging activated for testing"
    else
        console.clear       
    end if
    console.log "hello "
    console.warn "warning"
    console.error "error"
    console.assert true, "should not see this"
    console.assert false, "Assertion"
    on error resume next
    f=1/0
    console.Error "" ' logs the Err object
    on error goto 0
    console.logVar "now"
    console.groupCollapsed "My collapsed group"
        console.log "L1"
        console.warn "W1"
        console.error "E1"
    console.groupEnd
    console.group "My group"
        console.log "L1"
        console.warn "W1"
        console.error "E1"
    console.groupEnd
    console.active = false
    console.error "can't see this"
    console.active = true
    console.log "should see that"
end sub


%>

'样本使用-参见底部的单元测试
'要打开日志记录,您有以下选项:
'console.active=true
'在本地主机上运行
'添加查询字符串日志=1(例如www.myweb.com?log=1)
类固结
私家侦探
私有oGroup
专用标签
私有管理器组类型
私有子类\u初始化()
isActive=(Request.ServerVariables(“服务器名称”)=“本地主机”)或_
(request.queryString(“log”)=“1”)或_
会话(“日志”)
set oGroup=nothing
端接头
公共财产出租(a)
isActive=a
会话(“日志”)=cBool(a)
端属性
公共财产变得活跃起来
活跃的
端属性
专用子脚本(func,文本)
如果未激活,则退出子系统
text=replace(文本“,”替换)
如果不是oGroup,那么oGroup什么都不是
oGroup.add oGroup.count,func&(“”&text&“”)
其他的
回应,写下“