Search code examples
tomcatservletssyslog

Accessing host information in server.xml from within servlet application


We have a site which is powered by spring mvc. I've added a bean that is Initalizing and ServletContextAware in which I modify the pattern to our syslog appender, adding database server, name, username etc.

I want to add something to the pattern that uniquely identifies the application/site. And the perfect thing would be to have the name attribute from host-tag in server.xml.

Is it possible to access that value from within the application code? Anyone have any other suggestion to a value that uniquely identifies the application/site I can make use of? I've thought of getContextPath but if the site is deployed at ROOT that won't help much.

Thanks


Solution

  • Used log4j MDC functionality which solved my problem pretty well.