<a id="control-center-logging-settings"></a>

# Manage Control Center Logs for Confluent Platform

Use this topic to enable and manage logs for Control Center.

## Control Center logging

Control Center and other Confluent Platform components use the Java-based logging utility
[Apache Log4j2](https://en.wikipedia.org/wiki/Log4j) to collect runtime data
and record component events. The following table describes each log level.

| Level   | Description                                                                       |
|---------|-----------------------------------------------------------------------------------|
| OFF     | Turns off logging.                                                                |
| FATAL   | Severe errors that cause premature termination.                                   |
| ERROR   | Other runtime errors or unexpected conditions.                                    |
| WARN    | Runtime situations that are undesirable or unexpected, but not necessarily wrong. |
| INFO    | Runtime events of interest at startup and shutdown.                               |
| DEBUG   | Detailed diagnostic information about events.                                     |
| TRACE   | Detailed diagnostic information about everything.                                 |

By default, Control Center writes `INFO`, `WARN`, `ERROR`, and `FATAL`
information to standard output (stdout). If you want to see all events,
you can set `DEBUG` or `TRACE` logging levels.

You can select your desired log4j2 configuration by
setting the `CONTROL_CENTER_log4j2_OPTS` environment variable
when starting Control Center.

Considerations:
: - Control Center logging has migrated to Log4j2 library.
  - Log4j library is no longer supported.
  - The Log4j2 library uses the `.yaml` format instead of `.properties`.
  - You must update any custom logging configurations to use the new Log4j2 yaml format.

## log4j2 yaml files

A default Control Center log4j2 template file is provided with Control Center. This yaml
file is located in the directory: `etc/confluent-control-center/log4j2.yaml`

The following shows an example of what the default log file contains:

```yaml
Configuration:
  status: WARN
  Appenders:
    Console:
      - name: Stdout
        Target: SYSTEM_OUT
        PatternLayout:
          pattern: "[%d{yyyy-MM-dd HH:mm:ss,SSS}] %p [%t] %m (%c)%n"

      - name: Streams
        PatternLayout:
          pattern: "[%d{yyyy-MM-dd HH:mm:ss,SSS}] %p [%t] %m (%c)%n"
        Filters:
          - Log4jRateFilter:
              level: WARN
              rate: 25

  Loggers:
    Root:
      level: info
      AppenderRef:
        - ref: Stdout

    Logger:
      - name: org.apache.kafka.streams
        level: info
        AppenderRef:
          - ref: Streams
        additivity: false

      - name: io.confluent.controlcenter.streams
        level: info
        AppenderRef:
          - ref: Streams
        additivity: false

      - name: kafka
        level: info
        AppenderRef:
          - ref: Stdout

      - name: org.apache.kafka
        level: info
        AppenderRef:
          - ref: Stdout

      - name: org.apache.kafka.clients.consumer
        level: info
        AppenderRef:
          - ref: Stdout

      - name: org.apache.zookeeper
        level: warn
        AppenderRef:
          - ref: Stdout

      - name: org.I0Itec.zkclient
        level: warn
        AppenderRef:
          - ref: Stdout
```

Confluent also provides `etc/confluent-control-center/log4j2-rolling.yaml`
as an example of setting up Control Center with rolling log
files that simplify log management. The rolling log file creates three, size-limited log files
that isolate information:

* `control-center.log` - Control Center, HTTP activity, anything not related to streams, REST API calls
* `control-center-streams.log` - Streams
* `control-center-kafka.log` - Client, ZooKeeper, and Kafka

The following shows an example of what the rolling log file contains:

```yaml
Configuration:
  status: WARN
  name: Log4j2Config

  Appenders:
    RollingFile:
    - name: Main
      fileName: ${sys:confluent.controlcenter.log.dir}/control-center.log
      filePattern: ${sys:confluent.controlcenter.log.dir}/control-center-%i.log
      PatternLayout:
        pattern: "[%d{yyyy-MM-dd HH:mm:ss,SSS}] %p [%t] %m (%c)%n"
      Policies:
        SizeBasedTriggeringPolicy:
          size: 10MB
      DefaultRolloverStrategy:
        max: 5

    - name: Streams
      fileName: ${sys:confluent.controlcenter.log.dir}/control-center-streams.log
      filePattern: ${sys:confluent.controlcenter.log.dir}/control-center-streams-%i.log
      PatternLayout:
        pattern: "[%d{yyyy-MM-dd HH:mm:ss,SSS}] %p [%t] %m (%c)%n"
      Policies:
        SizeBasedTriggeringPolicy:
          size: 10MB
      DefaultRolloverStrategy:
        max: 5
      Filters:
        - Log4jRateFilter:
            level: WARN
            rate: 25

    - name: Kafka
      fileName: ${sys:confluent.controlcenter.log.dir}/control-center-kafka.log
      filePattern: ${sys:confluent.controlcenter.log.dir}/control-center-kafka-%i.log
      PatternLayout:
        pattern: "[%d{yyyy-MM-dd HH:mm:ss,SSS}] %p [%t] %m (%c)%n"
      Policies:
        SizeBasedTriggeringPolicy:
          size: 10MB
      DefaultRolloverStrategy:
        max: 5

  Loggers:
    Root:
      level: info
      AppenderRef:
        - ref: Main

    Logger:
      - name: org.apache.kafka.streams
        level: info
        AppenderRef:
          - ref: Streams
        additivity: false

      - name: io.confluent.controlcenter.streams
        level: info
        AppenderRef:
          - ref: Streams
        additivity: false

      - name: kafka
        level: info
        AppenderRef:
          - ref: Kafka
        additivity: false

      - name: org.apache.kafka
        level: info
        AppenderRef:
          - ref: Kafka
        additivity: false

      - name: org.apache.zookeeper
        level: warn
        AppenderRef:
          - ref: Kafka
        additivity: false

      - name: org.I0Itec.zkclient
        level: warn
        AppenderRef:
          - ref: Kafka
        additivity: false
```

You can add additional entries and change log levels by updating these
configuration files.

## Enable logs for Control Center

You set your logging configuration with a Control Center environment variable at start up.

To set the logging configuration for Control Center:

* Set and export the `CONTROL_CENTER_log4j2_OPTS` environment variable similar to this example:
  ```bash
  export CONTROL_CENTER_log4j2_OPTS='-Dlog4j2.configuration=file:/etc/confluent-control-center/<log4j2.yaml>'
  ```

You must restart Control Center to apply changes to logging with an environment variable. For more information, see
[Restarting Control Center](properties.md#c3-restart).

## Change log levels for Control Center

You can change log levels to help debug issues. The following commands show how to set root logging
levels to **DEBUG** or **TRACE**.

- To enable debug logging, change the log level to `DEBUG` at the root level:
  ```yaml
    Loggers:
      Root:
        level: debug
        AppenderRef:
          - ref: Stdout
  ```
- To enable trace logging, change the root logger to `TRACE` at the root level:
  ```yaml
    Loggers:
      Root:
        level: trace
        AppenderRef:
          - ref: Stdout
  ```

When you are done debugging and tracing, reset the log levels back to their defaults and restart Control Center. For more information, see
[Restarting Control Center](properties.md#c3-restart).

## Set custom log directory location

The location the logs are written depends on the type of installation.

- RPM/Debian installation: `/var/log/kafka`
- ZIP/TAR installation: `$base_dir/logs`

You set a custom logging location with an environment variable at start up. To
set a custom location, use the following environment variable:

- `LOG_DIR`

To set the custom location for logs:

* Set and export the `LOG_DIR` environment variable similar to this example:
  ```bash
  export LOG_DIR='/my/logs/'
  ```

You must restart Control Center to apply changes to logging with an environment variable. For more information, see
[Restarting Control Center](properties.md#c3-restart).

If you are using Ansible Playbooks for Confluent Platform, use the variable `control_center_log_dir` to
write Control Center logs to a custom directory. For more information, see [Ansible Playbooks for Confluent Platform](https://docs.confluent.io/ansible/current/overview.html).

## Related content

- [Log redaction](/platform/current/security/protect-data/log-redaction.html#log-redaction)
