Questo contenuto non è disponibile nella lingua selezionata.

Chapter 3. Cluster logging


3.1. Configuring log settings for Serving and Eventing

You can configure logging for OpenShift Serverless Serving and OpenShift Serverless Eventing using the KnativeServing and KnativeEventing custom resource (CR). The level of logging is determined by the specified loglevel value.

3.1.1. Supported log levels

The following loglevel values are supported:

Expand
Table 3.1. Supported log levels
Log levelDescription

debug

Fine-grained debugging

info

Normal logging

warn

Unexpected but non-critical errors

error

Critical errors; unexpected during normal operation

dpanic

In debug mode, trigger a panic (crash)

Warning

Using the debug level for production might negatively affect performance.

3.1.2. Configuring log settings

You can configure logging for Serving and Eventing in the KnativeServing custom resource (CR) and KnativeEventing CR.

Procedure

  • Configure the log settings for Serving and Eventing by setting or modifying the loglevel value in the KnativeServing and KnativeEventing CR respectively. Here are two example configurations with all possible logging options set to level info:

    KnativeServing CR

    apiVersion: operator.knative.dev/v1beta1
    kind: KnativeServing
    metadata:
      name: knative-serving
      namespace: knative-serving
    spec:
      config:
        logging:
          loglevel.controller: "info"
          loglevel.autoscaler: "info"
          loglevel.queueproxy: "info"
          loglevel.webhook: "info"
          loglevel.activator: "info"
          loglevel.hpaautoscaler: "info"
          loglevel.net-certmanager-controller: "info"
          loglevel.net-istio-controller: "info"
          loglevel.net-kourier-controller: "info"
    Copy to Clipboard Toggle word wrap

    KnativeEventing CR

    apiVersion: operator.knative.dev/v1beta1
    kind: KnativeEventing
    metadata:
      name: knative-eventing
      namespace: knative-eventing
    spec:
      config:
        logging:
          loglevel.controller: "info"
          loglevel.eventing-webhook: "info"
          loglevel.inmemorychannel-dispatcher: "info"
          loglevel.inmemorychannel-webhook: "info"
          loglevel.mt-broker-controller: "info"
          loglevel.mt_broker_filter: "info"
          loglevel.mt_broker_ingress: "info"
          loglevel.pingsource-mt-adapter: "info"
    Copy to Clipboard Toggle word wrap

3.1.3. Configuring request log settings

You can configure request logging for your service in the observability field of your KnativeServing custom resource (CR).

For information about the available parameters for configuring request logging, see "Parameters of request logging".

Procedure

  • Configure request logging for your service by modifying the observability field in your KnativeServing CR:

    Example KnativeServing CR

    apiVersion: operator.knative.dev/v1beta1
    kind: KnativeServing
    metadata:
      name: knative-serving
      namespace: knative-serving
    # ...
    spec:
      config:
        observability:
            logging.enable-request-log: true
            logging.enable-probe-request-log: true
            logging.request-log-template: '{"httpRequest": {"requestMethod": "{{.Request.Method}}", "requestUrl": "{{js .Request.RequestURI}}", "requestSize": "{{.Request.ContentLength}}", "status": {{.Response.Code}}, "responseSize": "{{.Response.Size}}", "userAgent": "{{js .Request.UserAgent}}", "remoteIp": "{{js .Request.RemoteAddr}}", "serverIp": "{{.Revision.PodIP}}", "referer": "{{js .Request.Referer}}", "latency": "{{.Response.Latency}}s", "protocol": "{{.Request.Proto}}"}, "traceId": "{{index .Request.Header "X-B3-Traceid"}}"}'
    # ...
    Copy to Clipboard Toggle word wrap

3.1.4. Parameters of request logging

The following table describes parameters used to configure request logging.

Expand
Table 3.2. Request logging configuration parameters
ParameterTypeDescription

logging.enable-request-log

Boolean (true or false)

Set to true to enable request logging.

logging.enable-probe-request-log

Boolean (true or false)

Set to true to enable the queue proxy to log probe requests to stdout. It uses the template specified in logging.request-log-template.

logging.request-log-template

Go text/template string

Determine the shape of the request logs. Use a single line to prevent logs from being split into multiple records.

The logging.request-log-template parameter includes the following functions:

  • Request is an http.Request representing an HTTP request received by the server.
  • Response represents the HTTP response and includes the following fields:

    • Code is the HTTP status code.
    • Size is the response size in bytes.
    • Latency is the response latency in seconds.
  • Revision contains revision details and includes the following fields:

    • Name is the name of the revision.
    • Namespace is the namespace of the revision.
    • Service is the name of the service.
    • Configuration is the name of the configuration.
    • PodName is the name of the pod hosting the revision.
    • PodIP is the IP address of the hosting pod.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat