Karussell
Karussell

Reputation: 17375

Logging configuration for dropwizard to log everything into one file with custom log format

I'm using dropwizard 0.9.2 and had to upgrade jackson to 2.7.3 to make the following configuration at least starting:

server:
  applicationConnectors:
    - type: http
      port: 8080

  adminConnectors:
    - type: http
      port: 8081

  requestLog:
    timeZone: UTC
    appenders:
      - type: console  
        logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
      - type: file
        currentLogFilename: ./logs/vrp-app.log
        archivedLogFilenamePattern: ./logs/vrp-app.%d.log.gz
        logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"

logging:
  level: INFO
  loggers:
    "org.hibernate":
      level: DEBUG
  appenders:
    - type: console
      timeZone: UTC
      logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
    - type: file
      timeZone: UTC
      currentLogFilename: ./logs/vrp-app.log
      archivedLogFilenamePattern: ./logs/vrp-app.%d.log.gz
      archivedFileCount: 5
      logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"

But still the log format of the request log is different than the rest:

15:46:42.717 [main] INFO  org.eclipse.jetty.server.Server - Started @3751ms
127.0.0.1 - - [14/Jun/2016:13:46:48 +0000] "GET /users HTTP/1.1" 415 56 "-" "curl/7.35.0" 136

Just keeping the "-type" lines in the hope that the config is picked from the logging section also does not work.

What am I doing wrong?

This should work according to this discussion

And is it okay to specify the same log for request log and 'normal log'. Why is this separated at all?

Upvotes: 2

Views: 2498

Answers (1)

balaji
balaji

Reputation: 11

requestLog logFormat is not implemented for 0.9.2. You have to move to 1.0.0-rc3 (latest) dropwizard version.

And the formatting is bit different as specified in http://logback.qos.ch/access.html

more ref: https://www.loggly.com/ultimate-guide/apache-logging-basics/

Upvotes: 1

Related Questions