博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
asp中日志方法
阅读量:4572 次
发布时间:2019-06-08

本文共 5391 字,大约阅读时间需要 17 分钟。

代码文件log.asp中内容如下:

<%    Function getPath()        getPath = request.servervariables("APPL_PHYSICAL_PATH")    End Function    Function getScriptName()        sName = request.servervariables("SCRIPT_NAME")        getScriptName = sName    End Function    Sub writeLog(logMsg, strSQL)        f_YY=CStr(Year(Now()))        If( Month(Now()) < 10 ) Then            f_MM="0" & CStr(Month(Now()))        Else            f_MM=CStr(Month(Now()))        End if        If( day(Now()) < 10 ) Then            f_DD="0" & CStr(day(Now()))        Else            f_DD=CStr(day(Now()))        End if        'f_date    = FormatDateTime(date,2)        f_date1    = f_YY & f_MM & f_DD              pathname = "D:\LOG\" & Request.ServerVariables("REMOTE_ADDR") & "-" &  f_date1    & ".log" 'formatdatetime(Date, 1) FormatDateTime(Now(),1)        set fso = server.CreateObject("scripting.filesystemobject")        if fso.fileExists(pathname) then                       set ofile = fso.OpenTextFile(pathname,8,true)        else            set ofile = fso.CreateTextFile(pathname,true)        end If        ofile.Writeline "[" & Now & "-" & getScriptName() & "]" & chr(13) & chr(10)        ofile.Writeline logMsg & chr(13) & chr(10)        ofile.Writeline strSQL & chr(13) & chr(10)        ofile.close        set ofile = nothing        set fso = nothing    End Sub%>

 

参考资料:

ASP ServerVariables 集合

定义和用法

ServerVariables 集合用于取回服务器变量的值。

语法

Request.ServerVariables (server_variable)

 

服务器变量列表:

变量 描述
ALL_HTTP Returns all HTTP headers sent by the client. Always prefixed with HTTP_ and capitalized
ALL_RAW Returns all headers in raw form
APPL_MD_PATH Returns the meta base path for the application for the ISAPI DLL
APPL_PHYSICAL_PATH Returns the physical path corresponding to the meta base path
AUTH_PASSWORD Returns the value entered in the client's authentication dialog
AUTH_TYPE The authentication method that the server uses to validate users
AUTH_USER Returns the raw authenticated user name
CERT_COOKIE Returns the unique ID for client certificate as a string
CERT_FLAGS bit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the cCertification authority of the client certificate is not valid
CERT_ISSUER Returns the issuer field of the client certificate
CERT_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
CERT_SECRETKEYSIZE Returns the number of bits in server certificate private key
CERT_SERIALNUMBER Returns the serial number field of the client certificate
CERT_SERVER_ISSUER Returns the issuer field of the server certificate
CERT_SERVER_SUBJECT Returns the subject field of the server certificate
CERT_SUBJECT Returns the subject field of the client certificate
CONTENT_LENGTH Returns the length of the content as sent by the client
CONTENT_TYPE Returns the data type of the content
GATEWAY_INTERFACE Returns the revision of the CGI specification used by the server
HTTP_<HeaderName> Returns the value stored in the header HeaderName
HTTP_ACCEPT Returns the value of the Accept header
HTTP_ACCEPT_LANGUAGE Returns a string describing the language to use for displaying content
HTTP_COOKIE Returns the cookie string included with the request
HTTP_REFERER Returns a string containing the URL of the page that referred the request to the current page using an <a> tag. If the page is redirected, HTTP_REFERER is empty
HTTP_USER_AGENT Returns a string describing the browser that sent the request
HTTPS Returns ON if the request came in through secure channel or OFF if the request came in through a non-secure channel
HTTPS_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
HTTPS_SECRETKEYSIZE Returns the number of bits in server certificate private key
HTTPS_SERVER_ISSUER Returns the issuer field of the server certificate
HTTPS_SERVER_SUBJECT Returns the subject field of the server certificate
INSTANCE_ID The ID for the IIS instance in text format
INSTANCE_META_PATH The meta base path for the instance of IIS that responds to the request
LOCAL_ADDR Returns the server address on which the request came in
LOGON_USER Returns the Windows account that the user is logged into
PATH_INFO Returns extra path information as given by the client
PATH_TRANSLATED A translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping
QUERY_STRING Returns the query information stored in the string following the question mark (?) in the HTTP request
REMOTE_ADDR Returns the IP address of the remote host making the request
REMOTE_HOST Returns the name of the host making the request
REMOTE_USER Returns an unmapped user-name string sent in by the user
REQUEST_METHOD Returns the method used to make the request
SCRIPT_NAME Returns a virtual path to the script being executed
SERVER_NAME Returns the server's host name, DNS alias, or IP address as it would appear in self-referencing URLs
SERVER_PORT Returns the port number to which the request was sent
SERVER_PORT_SECURE Returns a string that contains 0 or 1. If the request is being handled on the secure port, it will be 1. Otherwise, it will be 0
SERVER_PROTOCOL Returns the name and revision of the request information protocol
SERVER_SOFTWARE Returns the name and version of the server software that answers the request and runs the gateway
URL Returns the base portion of the URL

  

 

 

 

转载于:https://www.cnblogs.com/iframe/p/5887842.html

你可能感兴趣的文章
给laravel项目集成支付宝
查看>>
安装prometheus+grafana监控mysql redis kubernetes等
查看>>
Java眼中的XML--文件读取--1 应用DOM方式解析XML
查看>>
C++使用递归函数计算阶乘
查看>>
linker command failed with exit code 1 (use -v to see invocation)报错解决办法
查看>>
通用EF框架
查看>>
5-Java多态性理解
查看>>
vray学习笔记(4)混合材质是个什么东西
查看>>
Redis Linux版安装详解
查看>>
软件工程个人作业02------即01的升级版本
查看>>
博弈论 斯坦福game theory stanford week 3.1_
查看>>
HDU1286+线性筛素数
查看>>
JavaScript简单的实例应用
查看>>
caffe中各种cblas的函数使用总结
查看>>
功能性肠道疾病用药一览表
查看>>
模板页
查看>>
BZOJ 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐
查看>>
异步编程
查看>>
MySQL 5.7 reference about JSON
查看>>
十进制整数转化十六进制
查看>>