Reputation: 2020
I'd like to see some of the property settings in my log of what the java server is initialized with. Not on each request just at startup. How can I set that up?
Upvotes: 1
Views: 44
Reputation: 362
One way to do it might be to create a ServletContextListener
that logs the properties in the contextInitialized
method. For example:
public class LoggingServletContextListener
implements ServletContextListener {
private static final Logger logger = LogManager.getLogger(LoggingServletContextListener.class);
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
logger.info(System.getProperties());
}
}
You would need to include the listener in your web.xml
file. You can read more about ServletContextListener
here:
Upvotes: 2