b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

Tomcat的访问日志-localhost_access_log和记录Post请求参数

电脑杂谈  发布时间:2019-06-24 02:05:07  来源:网络整理

tomcat debug日志_tomcat日志分类_tomcat 日志分类

est.getAttribute('tkq')为空的时候,该条日志才会被记录下来。

fileDateFormat

顾名思义,就是时间格式嘛。但这个时间格式是针对日志文件名起作用的。咱们生成的日志文件全名:localhost_access_log.2016-09-22.txt,这里面的2016-09-22就是这么来的。如果想让tomcat每小时生成一个日志文件,也很简单,将这个值设置为:fileDateFormat='yyyy-MM-dd.HH',当然也可以按分钟生成什么的,自己改改吧^_^

tomcat 日志分类_tomcat debug日志_tomcat日志分类

具体的日志产生样式说明如下(从官方文档中摘录)

* %a - Remote IP address // 这是记录访问者的IP,在日志里是127.0.0.1 * %A - LocalIP address // 这是记录本地服务器的IP,在日志里是192.168.254.108 * %b - Bytes sent,excluding HTTP headers, or '-' if zero //发送信息的字节数,不包括http头,如果字节数为0的话,显示为- * %B - Bytes sent, excluding HTTPheaders // 发送信息的字节数,不包括http头。 * %h - Remote host name (or IPaddress if resolveHosts is false)//服务器的名称。如果resolveHosts为false的话,这里就是IP地址了,例如我的日志里是10.217.14.16 * %H- Request protocol //访问者的协议,这里是HTTP/1.0 * %l - Remote logicalusername from identd (always returns '-') // 官方解释:Remote logicalusername from identd (可能这样翻译:记录浏览者进行身份验证时提供的名字)(always returns '-')* %m - Request method (GET, POST, etc.) // 访问的方式,是GET还是POST * %p -Local port on which this request was received // 本地接收访问的端口 * %q -Query string (prepended with a '?' if it exists) //比如你访问的是aaa.jsp?bbb=ccc,那么这里就显示?bbb=ccc,就是querystring的意思 * %r -First line of the request (method and request URI) // First line ofthe request (method and request URI) 请求的方法和URL * %s - HTTP statuscode of the response // http的响应状态码 * %S - User session ID //用户的session ID,这个session ID大家可以另外查一下详细的解释,反正每次都会生成不同的session ID * %t- Date and time, in Common Log Format // 请求时间 * %u - Remote userthat was authenticated (if any), else '-' // 得到了验证的访问者,否则就是'-' * %U- Requested URL path // 访问的URL地址,我这里是/rightmainima/leftbott4.swf *%v - Local server name // 服务器名称,可能就是你url里面写的那个吧,我这里是localhost* %D -Time taken to process the request, in millis // 请求消耗的时间,以毫秒记 * %T -Time taken to process the request, in seconds //请求消耗的时间,以秒记 Thereis also support to write information from the cookie, incomingheader, the Session or something else in the ServletRequest. It ismodeled after the apache syntax:* %{xxx}i for incoming headers*%{xxx}c for a specific cookie* %{xxx}r xxx is an attribute in theServletRequest* %{xxx}s xxx is an attribute in theHttpSession

示例【格式为

tomcat debug日志_tomcat日志分类_tomcat 日志分类

%h %l %u %t '%r' %s %b】

140.205.201.39 - - [31/Aug/2017:17:06:52 +0800] 'GET /clusters.jsfHTTP/1.1' 404 -60.191.38.77 - - [31/Aug/2017:17:11:35 +0800] 'GET /HTTP/1.1' 404 -61.232.253.54 - - [31/Aug/2017:19:04:53 +0800] 'GET/ HTTP/1.1' 404 -100.116.151.190 - - [31/Aug/2017:20:45:17 +0800]'GET /CloudPayment/bill/querySelfPayList.do HTTP/1.0' 20060100.116.41.2 - - [31/Aug/2017:20:45:34 +0800] 'GET/CloudPayment/user/pay.do HTTP/1.0' 200 1422100.116.151.145 - -[31/Aug/2017:20:46:22 +0800] 'GET /CloudPayment/user/pay.doHTTP/1.0' 200 1422100.116.41.41 - - [31/Aug/2017:20:46:42 +0800]'GET /CloudPayment/user/pay.do HTTP/1.0' 200 1422100.116.151.181 -- [31/Aug/2017:20:47:21 +0800] 'GET /CloudPayment/user/pay.doHTTP/1.0' 200 1422100.116.151.181 - - [31/Aug/2017:20:47:22 +0800]'GET /CloudPayment/user/pay.do HTTP/1.0' 200 1422

记录Post请求参数

tomcat debug日志_tomcat 日志分类_tomcat日志分类

如果 session 中已经有 csrftoken,则说明用户已经与服务器之间建立了一个活跃的 session,这时要看这个请求中有没有同时附带这个 token,由于请求可能来自于常规的访问或是 xmlhttprequest 异步访问,我们分别尝试从请求中获取 csrftoken 参数以及从 http 头中获取 csrftoken 自定义属性并与 session 中的值进行比较,只要有一个地方带有有效 token,就判定请求合法,可以继续执行,否则就转到错误页面。还可以指定method方式来达到动态调用的目的,在配置action的时候,可以执行method属性来指定调用action的哪个方法来处理请求,这样也能达到动态调用的目的。在系统部署上,前端项目和服务端项目都采用分布式方式,用户请求进入前先通过负载均衡设备进行请求分发tomcat 日志分类,前端和服务端之间以及服务端和之间有防火墙保证系统的安全性,前端的集群和服务端集群分属到不同网络环境里tomcat 日志分类,前端集群可以访问外网,服务端集群和所在网络不能直接访问外网,但是前端网络环境和服务端网络环境之间可以进行通信。

server.xml配置

tomcat访问日志格式配置,在config/server.xml里Host标签下加上

tomcat 日志分类_tomcat debug日志_tomcat日志分类

<</span>ValveclassName='org.apache.catalina.valves.AccessLogValve'directory='logs' prefix='localhost_access_log.' suffix='.txt'pattern='%h %l %u %t "%r" [%{postdata}r] %s %{Referer}i%{User-Agent}i %T %b' />

postdata过滤器

package com。xiaoxiliuimport java。io。IOException;importjava。util。Enumeration;import javax。servlet。Filter;importjavax。servlet。FilterChain;import javax。servlet。FilterConfig;importjavax。servlet。ServletException;importjavax。servlet。ServletRequest;importjavax。servlet。ServletResponse;import org。slf4j。Logger;importorg。slf4j。LoggerFactory;public final class PostDataDumperFilterimplements Filter { Logger logger =LoggerFactory。getLogger(getClass()); private FilterConfigfilterConfig = null; public void destroy() { this。

filterConfig =null; } public void doFilter(ServletRequest request,ServletResponse response, FilterChain chain) throws IOException,ServletException { if (filterConfig == null) return; Enumerationnames = request。getParameterNames(); StringBuilder output = newStringBuilder(); while (names。hasMoreElements()) { String name =(String) names。nextElement(); output。append(name)。append('=');String values[] = request。getParameterValues(name); for (int i = 0;i < values。length; i++) { if (i > 0) { output。

append('' '); }output。append(values[i]); } if (names。hasMoreElements())output。append('&'); } request。setAttribute('postdata', output);logger。debug('postdata: ' + output); chain。doFilter(request,response); } public void init(FilterConfig filterConfig) throwsServletException { this。filterConfig = filterConfig; }}

在web.xml中添加配置该filter

post-data-dumper-filter com.xiaoxiliu.PostDataDumperFilterpost-data-dumper-filter /*


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-108003-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      • 艾力克
        艾力克

        意思是让你们自己掏钱买房

      • 李舒
        李舒

        只是对于大多数人而言

      • 岳铭
        岳铭

        全国人民恭喜南方黑芝麻蛆子节节高

      热点图片
      拼命载入中...