Custom Log Format for Request Logger

2,362 views
Skip to first unread message

Javier Campanini

unread,
Oct 27, 2014, 1:08:20 PM10/27/14
to dropwiz...@googlegroups.com
I'm trying to get a custom log format for the Request Logger. In particular, something like this:

server:
  requestLog
:
    appenders
:
     
- type: console
        logFormat
: an-actual-log-format-here %m%n


But in practice, I can't get the log format to be respected by the Request Logger. It seems the chain of events are:
My questions are:
  1. Is there a way to set the pattern for the Request Logger?
  2. Is this a bug that the pattern for the request logger is ignored?
Thanks,
-javi

Jamie Furness

unread,
Oct 27, 2014, 1:56:57 PM10/27/14
to dropwiz...@googlegroups.com

Hi Javier. At current Dropwizard uses the Jetty NSCA request logger, that doesn't support custom formats. There is a pull request (#580) that changes Dropwizard to use logback-access which would do exactly what you want, though it's blocked on the next version of logback being released. I haven't had any word from the developers if this is likely to be merged once logback is updated, but I hope so.

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Javier Campanini

unread,
Oct 27, 2014, 2:58:30 PM10/27/14
to dropwiz...@googlegroups.com
Jamie,

As a temporary solution, I'm planning on writing a custom appender that extends Console, where the build method does one thing: calls the super.build() with a null for layout. That way it'll build a normal DropwizardLayout.

Would that cause any problems? Is this a viable solution?

Thanks!
-javi

Javier Campanini

unread,
Oct 28, 2014, 2:01:00 AM10/28/14
to dropwiz...@googlegroups.com
To go into more detail:

We're attempting to add the username to the request log. We're using Shiro for authentication, and using a Servlet Filter to pull the username into the org.slf4j.MDC.

Our resulting pattern is:
%mdc{user:-anon} - %m%n%xEx

Georg Meyer

unread,
May 8, 2015, 9:11:51 AM5/8/15
to dropwiz...@googlegroups.com
Any news on this one? This is not integrated into dropwizard 8.1, right?

Carlo Barbara

unread,
May 8, 2015, 9:44:42 AM5/8/15
to dropwiz...@googlegroups.com
It's not implemented, and there is not commitment on a timeline.

avinash katika

unread,
May 12, 2016, 2:14:47 PM5/12/16
to dropwizard-user
Looks like https://github.com/dropwizard/dropwizard/issues/972 is comitted.

I have a similar requirement where I need to add  request port being used by request.Is that still feasible with approach. 

I don't see any information provided in Dropwizard regarding this.Any pointers where I could find more information customizing request log format.

JITENDRA GANGWAR

unread,
Jan 12, 2017, 3:55:36 PM1/12/17
to dropwizard-user
Hi Avinash , any luck on this ?
Reply all
Reply to author
Forward
0 new messages