[JAVA] Tomcat thread name

background

The thread name for each request was output by the access log of Tomcat and the logger such as Log4J, but the format of the thread name changed when various settings were changed.

Thread name

The thread name can be output by specifying "% I" for the access log of Tomcat and "% t" for the Log4J system. The image is as follows.

http-nio-127.0.0.1-8080-exec-1

The IP address and port of the server were output like this, but it ended up as follows.

http-nio-8080-exec-1

At my site, there are several servers, and I used fluentd to combine the logs of the application into one file, but since the IP address is no longer output, each line of the log tells which server the log is. It has become.

What i found

Apparently it was because I deleted the address attribute of the Connector tag in server.xml. If the address attribute is not set, it seems to be an optional attribute because it seems to listen on the IP of localhost. Therefore, it is presumed that the thread name format in Tomcat is as follows.

http-nio-[Address attribute of Connector tag]-[Port attribute of Connector tag]-exec-1

end.

Recommended Posts

Tomcat thread name
tomcat error