Skip to content

Document how swap to structured logging #64

@xphir

Description

@xphir

Summary

Please add official guidance (and example configuration) for turning on structured, machine-readable logging in Kafka-UI. JSON logs are easier to ingest and query in modern observability stacks.

Note:

There is probably a better way to do this if the logback-spring.xml did not exist, as the default spring-boot framework has some good inbuilt default that could be controlled just via config.

You could likely even maintain current behaviour defaulting logging.pattern.console to %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%c{1}): %msg%n%throwable

Motivation / use-case

  • Teams using tools such as Loki, Elastic, Datadog, or CloudWatch Logs benefit from consistent JSON output.
  • Clear documentation would remove trial-and-error for newcomers and promote best-practice adoption.

Example working setup

Below is a minimal configuration that produces JSON logs at INFO level. It can be included as an example or starting point in the docs.

Dockerfile
FROM ghcr.io/kafbat/kafka-ui:v1.2.0

# Copy the custom config file
COPY config.yaml /opt/config.yaml

# Copy the custom Logback file
COPY logback-spring.xml /opt/logback-spring.xml
config.yaml
...
logging:
  config: /opt/logback-spring.xml

  structured:
    format:
      console: logstash

  level:
    org.springframework.security: INFO
    io.kafbat.ui.service.rbac: INFO
...
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
      <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
        <level>${CONSOLE_LOG_THRESHOLD}</level>
      </filter>
      <encoder class="org.springframework.boot.logging.logback.StructuredLogEncoder">
        <format>${CONSOLE_LOG_STRUCTURED_FORMAT}</format>
        <charset>${CONSOLE_LOG_CHARSET}</charset>
      </encoder>
    </appender>

    <root level="INFO">
      <appender-ref ref="CONSOLE"/>
    </root>

</configuration>

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions