Search code examples
javaloggingslf4jlogbackdropwizard

DropWizard 0.7.1 logging file appender issues


using DW 0.7.1 I successfully see my http request logs with the following configuration:

server:
  requestLog:
      appenders:
        - type: file
          currentLogFilename: /var/test/http-test.log
          archivedLogFilenamePattern: /var/test/http-test-%d.log
          archivedFileCount: 5
          timeZone: UTC

however, with the logging yml entry for non http request logging configured as follows (using only the bare-bones definitions)

logging:
  # The default level of all loggers. 
  # Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
  level: ERROR
  appenders:
    - type: file
      currentLogFilename: /var/test/test.log
      archivedLogFilenamePattern: /var/test/test-%d.log
      archivedFileCount: 5
      timeZone: UTC

I NEVER see the logs at /var/test/

Instead, i see it the app just spool out default logging INFO level stuff, to console. Note: if i replace 'file' with console, the boot-strap start up tells me 'currentLogFilename isn't attribute of console' etc, so the DI is firing. It seems like if i use file though... I can't get it to go anywhere OTHER than console at default INFO levels.


Solution

  • I figured out what the issue was.

    my ApiConfiguration (extension of io.dropwizard.Configuration) had attempted to bind to 'logging' value, explicitly, as follows

    @Valid
    @NotNull
    @JsonProperty("logging")
    private LoggingFactory loggingFactory = new LoggingFactory();
    public LoggingFactory getLoggingFactory()
    {
        return loggingFactory;
    }
    

    on a hunch, i simply removed the binding in ApiConfiguration and now the logs write to my expected /var/test/ location at the expected log level.