asp中日志方法
代码文件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 |
asp中日志方法的更多相关文章
- ASP.NET中HttpApplication中ProcessRequest方法中运行的事件顺序;ASP.NET WebForm和MVC总体请求流程图
ASP.NET中HttpApplication中ProcessRequest方法中运行的事件顺序 1.BeginRequest 開始处理请求 2.AuthenticateRequest 授权验证请求 ...
- ASP中Utf-8与Gb2312编码转换乱码问题的解决方法 页面编码声明
ASP程序在同一个站点中,如果有UTF-8编码的程序,又有GB2312编码的程序时,在浏览UTF-8编码的页面后,再浏览当前网站GB2312的页面,GB2312编码的页面就会出现乱码 出现这样的问题是 ...
- 在ASP中调用DLL的方法
.net的dll已经不是严格意义上的动态连接库了,而是一个类或者类库.它是不能直接在ASP.VB等其它的应用环境中使用的. 我们可以通过COM包装器(COM callable wrapper (C ...
- ASP中文件上传组件ASPUpload介绍和使用方法
[导读]要实现该功能,就要利用一些特制的文件上传组件.文件上传组件网页非常多,这里介绍国际上非常有名的ASPUpload组件 1 下载和安装ASPUpload 要实现该功能,就要利用一些特制的文件上 ...
- FCKeditor 2.6.6在ASP中的安装及配置方法分享--ZZ转载自网络
FCKeditor目前的最新版本是2.6.6,在网上搜索此版本的配置方法,发现很少有asp的配置方法,以下就把自己的一些配置经验分享给有需要的你. 首先从FCKEditor官方下载最新的版本脚本之 ...
- Asp.net mvc 中Action 方法的执行(一)
[toc] 在 Aps.net mvc 应用中对请求的处理最终都是转换为对某个 Controller 中的某个 Action 方法的调用,因此,要对一个请求进行处理,第一步,需要根据请求解析出对应的 ...
- Log4j 配置某个类中某个方法的输出日志到指定文件
我们在项目中使用log4j开发的时候,会遇到一些特殊的情况,比如:要输出某个类中某个方法的日志信息到文件中,方便以后查看 可以使用如下配置: log4j.rootLogger=info,stdout ...
- 下载文件时-修改文件名字 Redis在Windows中安装方法 SVN安装和使用(简单版) WinForm-SQL查询避免UI卡死 Asp.Net MVC Https设置
下载文件时-修改文件名字 1后台代码 /// <summary> /// 文件下载2 /// </summary> /// <param name="Fil ...
- asp中设置session过期时间方法总结
http://www.jb51.net/article/31217.htm asp中设置session过期时间方法总结 作者: 字体:[增加 减小] 类型:转载 asp中默认session过期时间 ...
随机推荐
- 201521123028 《Java程序设计》第12周学习总结
1. 本周学习总结 流与文件 I/O流:Input/Output处理的简称,本质上就是一个数据序列.分为输入流Input Stream和输出流Output Stream. 最基本的可处理数据单位-by ...
- Java Build Path(Java 构建路径)
Java构建路径用于在编译Java项目时找到依赖的类,包括以下几项: 源码包 项目相关的 jar 包及类文件 项目引用的的类库 我们可以通过使用 Java 项目属性对话框中的 Java Build P ...
- mybatis教程:入门>>精通>>实战
以前曾经用过ibatis,这是mybatis的前身,当时在做项目时,感觉很不错,比hibernate灵活.性能也比hibernate好.而且也比较轻量级,因为当时在项目中,没来的及做很很多笔记.后来项 ...
- Hyperledger Fabric 1.0 从零开始(八)——Fabric多节点集群生产部署
6.1.平台特定使用的二进制文件配置 该方案与Hyperledger Fabric 1.0 从零开始(五)--运行测试e2e类似,根据企业需要,可以控制各节点的域名,及联盟链的统一域名.可以指定单独节 ...
- java向前引用
根据看书和看得文章,引出了一个关于"向前引用"的问题: public class InstanceInitTest { static { // { a = 6; System.ou ...
- Hibernate第五篇【inverse、cascade属性详解】
前言 上一篇博文已经讲解了一对多和多对一之间的关系了,一对多和多对一存在着关联关系(外键与主键的关系).本博文主要讲解Inverse属性.cascade属性.这两个属性对关联关系都有影响 Invers ...
- 接口测试入门(3)--使用httpClient进行登录用例操作/set-cookies验证/ List<NameValuePair>设置post参数/json解析
(最近学的都是很基础的接口测试,都是基于UI界面可见的接口,就是发请求,接收响应,分析返回的结果,校验,对共通模块进行封装,仅此而已,其实做自动化的思路基本都是如此,UI也是.) 现在开始用httpC ...
- Bootstrap Table急速完美搭建后台管理系统
Bootstrap Table是基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选.多选.排序.分页,以及编辑.导出.过滤(扩展)等等的功能:http://bo ...
- Ansible系列(三):YAML语法和playbook写法
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- [UIKit学习]01.关于UIView,frame,bounds,center
UIView是Cocoa大多控件的父类,本身不带事件. UIView的常见用法 @property(nonatomic,readonly) UIView *superview; 获得自己的父控件对象 ...