This is a cache of https://docs.okd.io/4.11/support/troubleshooting/diagnosing-oc-issues.html. It is a snapshot of the page at 2024-11-21T20:01:55.590+0000.
Diagnosing OpenShift <strong>cli</strong> (oc) issues - Troubleshooting | Support | OKD 4.11
×

Understanding OpenShift cli (oc) log levels

With the OpenShift cli (oc), you can create applications and manage OKD projects from a terminal.

If oc command-specific issues arise, increase the oc log level to output API request, API response, and curl request details generated by the command. This provides a granular view of a particular oc command’s underlying operation, which in turn might provide insight into the nature of a failure.

oc log levels range from 1 to 10. The following table provides a list of oc log levels, along with their descriptions.

Table 1. OpenShift cli (oc) log levels
Log level Description

1 to 5

No additional logging to stderr.

6

Log API requests to stderr.

7

Log API requests and headers to stderr.

8

Log API requests, headers, and body, plus API response headers and body to stderr.

9

Log API requests, headers, and body, API response headers and body, plus curl requests to stderr.

10

Log API requests, headers, and body, API response headers and body, plus curl requests to stderr, in verbose detail.

Specifying OpenShift cli (oc) log levels

You can investigate OpenShift cli (oc) issues by increasing the command’s log level.

The OKD user’s current session token is typically included in logged curl requests where required. You can also obtain the current user’s session token manually, for use when testing aspects of an oc command’s underlying process step-by-step.

Prerequisites
  • Install the OpenShift cli (oc).

Procedure
  • Specify the oc log level when running an oc command:

    $ oc <command> --loglevel <log_level>

    where:

    <command>

    Specifies the command you are running.

    <log_level>

    Specifies the log level to apply to the command.

  • To obtain the current user’s session token, run the following command:

    $ oc whoami -t
    Example output
    sha256~RCV3Qcn7H-OEfqCGVI0CvnZ6...