tomcat:我们如何在tomcat日志中记录用户名? [英] tomcat: how can we log user name in tomcat log?

查看:146
本文介绍了tomcat:我们如何在tomcat日志中记录用户名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试取消注释server.xml中的阀线.未注释的行是

I have tried uncomment the valve line in the server.xml. The uncommented lines are

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>

它仅记录正在访问的URL.它没有记录谁发出了请求.

It only logs the url being accessed. It did not log down who have made the request.

在tomcat中执行此操作的正确方法是什么?

What is the proper way to do it in tomcat?

推荐答案

您已选择通用"模式;您需要指定一种自定义模式,如下所示. %u"变量代表已认证的用户".下面的链接列出了您可以使用的所有其他变量.

You have selected the "common" pattern ; you need to specify a custom pattern like the one shown below. The "%u" variable stands for "authenticated user". The link below lists all the other variables you can use.

http://tomcat.apache.org/tomcat- 7.0-doc/config/valve.html#Access_Log_Valve

    <Valve className="org.apache.catalina.valves.AccessLogValve"
             directory="logs"  prefix="access." suffix=".log"
             pattern="%h %l %u %t '%r' %s %b"
             resolveHosts="false"/>

这篇关于tomcat:我们如何在tomcat日志中记录用户名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆