<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%t %a %A %p %r %q %s %B %D %{User-Agent}i %{Referer}i"
resolveHosts="false" />
这是我的server.xml,然后我发现结果是这样的:
在server.xml%A中的[29 / Mar / 2017:10:36:16 +0800] 192.168.5.149 127.0.0.1 80 GET /favicon.ico HTTP / 1.1 404 0 0 Mozilla / 5.0(Windows NT 6.1; Win64; x64; rv: 52.0)Gecko / 20100101 Firefox / 52.0 -
只给我循环ip,但我想要eth0 ip ..
那我该怎么办?非常感谢!
答案 0 :(得分:0)
$ hostname
yourhost
192.168.5.1 yourhost
仅供参考,Tomcat源代码:
/**
* write local IP address - %A
*/
protected static class LocalAddrElement implements AccessLogElement {
private static final String LOCAL_ADDR_VALUE;
static {
String init;
try {
init = InetAddress.getLocalHost().getHostAddress();
} catch (Throwable e) {
ExceptionUtils.handleThrowable(e);
init = "127.0.0.1";
}
LOCAL_ADDR_VALUE = init;
}
@Override
public void addElement(StringBuilder buf, Date date, Request request,
Response response, long time) {
buf.append(LOCAL_ADDR_VALUE);
}
}