gini / dropwizard-gelf

Addon bundle for Dropwizard to support logging to a GELF-enabled server like Graylog or logstash
http://developer.gini.net/dropwizard-gelf/1.3.0-1/
Apache License 2.0
52 stars 21 forks source link

requestLog is not being sent #19

Open madmuffin1 opened 8 years ago

madmuffin1 commented 8 years ago

Hi,

I am trying to also send the requestLog to our graylog server. Unfortunately, it does not work (messages are dropped silently). The instance is created correctly but messages cause a NPE in LogbackLogEvent.getCalleeStackTraceElement:74 since the callerDataArray in LogbackLogEvent.loggingEvent.getCallerData() is null.

My entries in the config section:

server:
  type: default # must be set, otherwise requestLog cannot be configured
  requestLog:
    appenders:
      - type: console
      - type: gelf
        host: udp:my.graylog.host
        port: 12201
        additionalFields:
          environment: ${ENVIRONMENT}
          type: access

Versions: Dropwizard 0.9.2, Dropwizard-GELF 0.9.2-4

Trundle commented 8 years ago

Hi,

I can confirm that there is a NPE in that case. Note that it's not because callerData is null, but rather due to loggerContext being null. I'm unsure yet whose fault that is.

Note that dropwizard-gelf comes with its own request logger (GelfLoggingFilter). To use it, add the following lines to your App#run() method:

environment.servlets()
    .addFilter("request-logs", new GelfLoggingFilter())
    .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
kevinmic commented 7 years ago

Debugging trying to figure out why my http requests aren't showing up in my logging server I found that the ch.qos.logback.core.AppenderBase is throwing a ClassCastException.

java.lang.ClassCastException: ch.qos.logback.access.spi.AccessEvent cannot be cast to ch.qos.logback.classic.spi.ILoggingEvent
    at biz.paluch.logging.gelf.logback.GelfLogbackAppender.append(GelfLogbackAppender.java:71)
    at ch.qos.logback.core.AppenderBase.doAppend(AppenderBase.java:82)
    at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)
    at ch.qos.logback.core.AsyncAppenderBase$Worker.run(AsyncAppenderBase.java:265)

So it appears that thad the RequestLog is sending an AccessEvent but the underlying logging structure can't handle that.

joschi commented 7 years ago

@kevinmic Which version of Dropwizard are you using?

kevinmic commented 7 years ago

io.dropwizard:dropwizard-core:jar:1.0.0

lennartkoopmann commented 7 years ago

I'm seeing the same issue. Dropwizard v1.1.2.