It is common that in a cluster we have to find out which Tomcat instance is used so that we can monitor the log files of that particular server only. When Tomcat is used as the application server, normally load balancing is done using Apache JK connector (mod_jk). JK connector adds name of actual instance to JSESSIONID cookie so that the connector can know how to route the request to the server which created the session. This works only when sticky session is used. When sticky session is not used, name of actual server is not appended to cookie and request is send to a server picked based on the load on each server. In this case, it is very difficult to identify actual Tomcat server.
When sticky session is not used, the solution I can think of is to use a filter that will set a cookie with a value that identifies unique name of the Tomcat instance. This filter should have configuration option to disable enable this cookie based on a configuration. Any changes to the configuration should be hot reloadable. By hot reloadable I mean that any changes to such configuration should be reloaded immediately or within few minutes in all the instances in a cluster. So this should be stored in a database or as a web service. By setting this configuration to true, the filter should set the cookie and when configuration is false, filter should not set the cookie. Doing so will avoid the need of deploy/restart of servers.
In production environment where numerous machines are used, this facility will help in isolating issues to particular servers. Then one has to check the particular server only.