ASP 실행 오류 함수 코드 캡처 및 저장
사용 방법:
on error resume next
' ,
call catch(" ")
기능: IIS의 오류 알림 정보를 제거하고 사용자 정의 오류 알림을 사용자에게 되돌려주며 오류 정보를 txt 파일에 저장합니다. (물론 사용자 정의 페이지로 이동하는 것도 수정할 수 있습니다.)
코드:
option explicit
' ---------------------------
' on error resume next , ,
on error resume next
'i , , catch
i
call catch(" ")
'-------------------------------
' ---------------------------
function conn()
' on error resume next
on error resume next
'...........
call catch(" ")
end function
'-------------------------------
sub catch(str)
if err.number <> 0 then
dim tmp,path
' , "/error_log.txt"
path = "/table/error_log.txt"
tmp = tmp & " :" & geturl & vbcrlf
tmp = tmp & " :" & now() & vbcrlf
tmp = tmp & " IP:" & ip & vbcrlf
tmp = tmp & " :" & str & vbcrlf
tmp = tmp & " :" & err.number & vbcrlf
tmp = tmp & " :" & err.description & vbcrlf
tmp = tmp & " :" & err.source & vbcrlf & vbcrlf & vbcrlf
tmp = tmp & file_read(path)
call file_save(tmp,path,1)
err.clear()
die(str)
end if
end sub
' catch --------------------
sub echo(str)
response.write(str)
end sub
sub die(str)
echo(str) : response.end()
end sub
function ip()
ip = request.servervariables("remote_addr")
end function
' URL
function geturl()
dim tmp
if lcase(request.servervariables("https")) = "off" then
tmp = "http://"
else
tmp = "https://"
end if
tmp = tmp & request.servervariables("server_name")
if request.servervariables("server_port") <> 80 then
tmp = tmp & ":" & request.servervariables("server_port")
end if
tmp = tmp & request.servervariables("url")
if trim(request.querystring) <> "" then
tmp = tmp & "?" & trim(request.queryString)
end if
geturl = tmp
end function
' :
function file_read(path)
dim tmp : tmp = "false"
if not file_exists(path) then file_read = tmp : exit function
dim stream : set stream = server.CreateObject("ADODB.Stream")
with stream
.type = 2 '
.mode = 3 '
.charset = "gb2312"
.open
.loadfromfile(server.MapPath(path))
tmp = .readtext()
end with
stream.close : set stream = nothing
file_read = tmp
end function
' :
function file_save(str,path,model)
if model<>0 and model<>1 then model=1
if model=0 and file_exists(path) then file_save=true : exit function
dim stream : set stream = server.CreateObject("ADODB.Stream")
with stream
.type = 2 '
.charset = "gb2312"
.open
.writetext str
.savetofile(server.MapPath(path)),model+1
end with
stream.close : set stream = nothing
file_save = file_exists(path)
end function
' : /
function file_exists(path)
dim tmp : tmp = false
dim fso : set fso = server.CreateObject("Scripting.FilesyStemObject")
if fso.fileexists(server.MapPath(path)) then tmp = true
if fso.folderexists(server.MapPath(path)) then tmp = true
set fso = nothing
file_exists = tmp
end function
%>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.