spec.logConfig 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.
The logConfig field has three subfields:
levelformattemplate
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.
format
The format field can be used to change the log format of the component. The value can be one of json, text.
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.
Change log level for a specific package
To change the log level for a specific package, first copy the content from the Apache Pulsar log4j2.yaml file into thetemplate field, then modify the log level for the desired package according to your requirements.
The following example shows how to change the log level for org.apache.pulsar.broker.service.ServerCnx:
name: Specifies the package name for which you want to change the log levellevel: Sets the log level (e.g.,debug,info,warn,error)additivity: Set tofalseto prevent logs from propagating to parent loggers, avoiding duplicate outputAppenderRef: Specifies the log output target, such asConsole