1
<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" />

This is my server.xml ,then i found the result is like this:

[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 -

in the server.xml %A just give me the loop ip, but i want eth0 ip ..

So what should i do? Thanks a lot!

Matt Clark
  • 27,671
  • 19
  • 68
  • 123
Betterc
  • 11
  • 1

1 Answers1

0
  1. Check host name:
$ hostname
yourhost
  1. Edit /etc/hosts and add:
192.168.5.1    yourhost

FYI, Tomcat source code:

/**
 * 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);
    }
}
Kohei TAMURA
  • 4,970
  • 7
  • 25
  • 49