-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
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
- Spring Boot logging guide (structured logging): https://docs.spring.io/spring-boot/3.4-SNAPSHOT/reference/features/logging.html#features.logging.structured
- Default structured-console-appender example: https://github.com/spring-projects/spring-boot/blob/3.4.x/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/structured-console-appender.xml
- Default spring boot logback file https://github.com/spring-projects/spring-boot/blob/3.4.x/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml
- Kafka UI logback file https://github.com/kafbat/kafka-ui/blob/main/api/src/main/resources/logback-spring.xml
Metadata
Metadata
Assignees
Labels
No labels