1. Operating StreamNative Platform
  2. Advanced

Configure Log Format

In the sn-platform 1.11 added a new feature called the logConfig which can be used to change the log level and log format of zookeeper, bookkeeper, broker and proxy. If logConfig field is configured, the component will use the mount path /mnt/conf/log4j2.yaml to mount the log configuration file, and can dynamically change the log level and log format of the component.

Note

To use the logConfig feature, you need to make sure already installed the pulsar-operator after 0.17.

The logConfig field has three subfields:

  • level
  • format
  • template

And use the Broker component as the example.

level

The level field can be used to change the log level of the component. The value can be one of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF.

broker:
  logConfig:
    level: "DEBUG"
    format: "text"
    template: {}

format

The format field can be used to change the log format of the component. The value can be one of json, text.

broker:
  logConfig:
    level: "INFO"
    format: "json"
    template: {}

template

The template field can totally replace the log4j2 config of the component, which would be useful if you need some customization more than level and format. The value of template is a string, which is the content of the log4j2 config file in yaml format.

broker:
  logConfig:
    level: "INFO"
    format: "text"
    template:
      Configuration:
        status: INFO
        monitorInterval: 30
        name: pulsar
        packages: io.prometheus.client.log4j2

        Loggers:
          Root:
            {{ if .Level }}
            level: "{{ .Level }}"
            {{ else }}
            level: "INFO"
            {{ end }}
            additivity: true
            AppenderRef:
              - ref: "${sys:pulsar.log.appender}"
                {{ if .Level }}
                level: "{{ .Level }}"
                {{ else }}
                level: "INFO"
                {{ end }}
              - ref: Prometheus
                level: info
Previous
Configure Pod Scheduling