Search code examples
filelogginghandlerperiodwildfly-swarm

Periodic-Rotating-File-Handler in yaml with Wildfly-Swarm not working


I want to configura a periodic-rotating-file-handler to log into a debugfile using wildfly-swarm. I want to do tgis using the project-defaults.yml

Currently I have the following:

swarm:
  logging:
    logging-profiles:
      root-logger:
        level: DEBUG
        handlers:
          - DEBUGFILE
          - CONSOLE
    periodic-rotating-file-handlers:
      DEBUGFILE:
        level: DEBUG
        enabled: true
        autoflush: true
        named-pattern: MY_PATTERN
        file:
          path: logs/debugfile.log
        suffix: .yyyy-MM-dd
     console-handlers:
      CONSOLE:
        level: DEBUG
        named-formatter: MY_PATTERN
    pattern-formatters:
      MY_PATTERN:
        pattern: "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p (%t) [%c] %s%e%n"
    loggers:
      de.myname:
        level: DEBUG

However, only the CONSOLE Logger gets registered and works as intended. The log/debugfile.log gets created, but stays empty. What can I do to fix this? Also, the CONSOLE log-level is always on INFO. Only the loggers.[de.myname].level part enables classes in there to log on debug. Why isn't it always in debug like I said in CONSOLE.level?


Solution

  • Not sure where the logging-profiles bit comes from, that sounds wrong. Also, since it's YAML, I think maybe console-handlers indentation might be wrong, but not sure about that.

    Here's a snippet that I tested to work correctly a while ago:

    swarm:
      logging:
        pattern-formatters:
          COLOR_PATTERN:
            pattern: "CUSTOM LOG FORMAT %p [%c] %s%e%n"
        periodic-rotating-file-handlers:
          FILE:
            file:
              path: target/foobar.log
            suffix: .yyyy-MM-dd
            named-formatter: COLOR_PATTERN
        root-logger:
          handlers:
          - CONSOLE
          - FILE