> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plerion.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Enable verbose logging

> Enable verbose logging in Plerion's collector manager to capture detailed diagnostic information for troubleshooting.

This guide explains how to enable detailed logging in the collector manager for troubleshooting.

By adding the `--zap-devel` flag to the `spec.containers.args` field in the collector manager deployment, you can enable debug logs. This increases log verbosity and provides more insight into potential issues.

<Warning>
  Running the collector manager with `--zap-devel` enabled is **not recommended** for regular operation. Use this mode only for diagnosing and resolving issues.
</Warning>

***

## Steps to enable verbose logging

<Steps>
  <Step title="Identify the collector manager deployment">
    Run the following command to list deployments in the `plerion-system` namespace:

    ```shell theme={"system"}
    kubectl get deployment -n plerion-system
    ```

    Example output:

    ```
    NAME                          READY   UP-TO-DATE   AVAILABLE   AGE
    plerion-collector-manager     2/2     2            2           10m
    ```
  </Step>

  <Step title="Edit the deployment configuration">
    Open the collector manager deployment in your editor:

    ```shell theme={"system"}
    kubectl edit deployment plerion-collector-manager -n plerion-system
    ```
  </Step>

  <Step title="Add the --zap-devel flag">
    In the editor, locate the collector manager container spec and add the `args` section:

    ```yaml theme={"system"}
    spec:
      containers:
        - name: collector-manager
          args:
            - --zap-devel
    ```
  </Step>

  <Step title="Save and exit the editor">
    Save the changes and exit the editor. The deployment will restart with verbose logging enabled.
  </Step>
</Steps>

***

## Example verbose log output

With the `--zap-devel` flag enabled, the collector manager generates more detailed logs.

**Example**:

```
2023-11-21T03:45:49Z INFO  setup  initializing controller
2023-11-21T03:45:49Z INFO  setup  fetching tenant config
2023-11-21T03:45:49Z DEBUG k8scbclient performing request {"method": "POST", "url": "https://au.app.plerion.com/api****/..."}
2023-11-21T03:45:50Z DEBUG k8scbclient request completed {"status": 200}
2023-11-21T03:45:50Z INFO  controller-runtime.metrics Metrics server is starting to listen {"addr": ":8080"}
2023-11-21T03:46:06Z INFO  setup Starting workers {"controller": "resourcecollector", "worker count": 1}
2023-11-21T03:46:06Z DEBUG setup.events plerion-collector-manager-5898cbc55c became leader {"type": "Normal", "reason": "LeaderElection"}
```

***

## Log analysis

Verbose logs can help identify root causes of issues. Key entries include:

* **GOMAXPROCS update**: System adjusts CPU allocation based on quota.
* **Controller initialization**: Collector manager starts and fetches tenant configuration.
* **HTTP request details**: Debugging information about API calls, including method, URL, and response code. Any response other than `200` or `204` should be investigated.
* **Metrics server setup**: Confirms the metrics server is running on port `8080`.
* **Leader lease acquisition**: Shows attempts and success in acquiring the Kubernetes leader lease.
* **Worker initialization**: Indicates that the controller components have successfully started.
