Search code examples
undertow

Logging an undertow embedded web server


I've got a simple main method running an Undertow web service. Pretty much taken from the basic example on their website. I'm trying to configure the logging which is appearing in my nohup.out file. I want to redirect it to a log file but can't find the magic command line parameters, or even better programatic configuration.

Also, I'd like to be able to log all the HTTP requests, is there an undertow request logger?


Solution

  • You need to configure logging for your application.

    For starters, you can use SLF4J with the SimpleLogger implementation. You can configure it easily with system properties, see SimpleLogger documentation

    Then you can use the Undertow RequestDumpingHandler to log the incoming requests in details.

    Simply wrap your handler:

    new RequestDumpingHandler(new YourHandler())...