Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Status

Current state:  Under Discussion. Accepted

Discussion threadhttps://www.mail-archive.com/dev@kafka.apache.org/msg99656.html

...

JIRA

Jira
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyKAFKA-7772

Released: 

Pull requesthttps://github.com/apache/kafka/pull/7403

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

...

This change will introduce an /admin/loggers endpoint to the Connect worker that can be used to get/modify the log levels of any named loggers in the Connect worker. In addition, a new configuration property admin.listeners will be provided to specify which listener to use for the /admin endpointThese modifications will not be persisted across worker restarts, and will only affect the worker whose endpoint received this REST request (other workers in the cluster will be unaffected). The /admin/loggers endpoint will support the following operations:

Get a list of all named loggers

Returns a list of loggers along with their current log levels. Entries are sorted by the logger's name. A named logger is one that is created by either the worker's classes using the LoggerFactory.getLogger method or is an ancestor denoted by the name of the package it corresponds to. Their levels are set by the log4j configuration file used by the worker JVM, or by using this API. 

Code Block
languagebash
$ curl -Ss http://localhost:8083/admin/loggers | jq
[
  ...
  "org.apache.kafka.connect.runtime.WorkerSinkTask": {
    "level": "INFO"
  },
  "org.apache.kafka.connect.runtime.WorkerSourceTask": {
    "level": "DEBUG"
  },
  ...
]

Get the log level of a specific logger

If the name of a logger is specified, only return the level to which that logger is writing messages at. This level may be set by a log4j configuration file, or by this API. If neither of those sources specified a level, log4j uses the level of an ancestor that was set by one of these means (the root logger's level is used if none of the other ancestor had a level set to it).

Code Block
languagebash
$ curl -Ss http://localhost:8083/admin/loggers/org.apache.kafka.connect.runtime.WorkerSinkTask | jq
{
   "level": "INFO"
}

Even if it is not used by any runtime classes to log any messages, requesting the level of an ancestor package will also return a log level using the above rules.

Code Block
languagebash
$ curl -Ss http://localhost:8083/admin/loggers/org.apache | jq
{
   "level": "INFO",
}

Set the log level of a specific logger

Use PUT to set the level of a logger. The API returns the list of loggers whose levels were modified.

Code Block
languagebash
$ curl -Ss -X PUT '{"level": "TRACE"}' http://localhost:8083/admin/loggers/org.apache.kafka.connect.runtime.WorkerSinkTask
{
  modified: [
    "org.apache.kafka.connect.runtime.WorkerSinkTask"
  ]
}

Setting the log level of an ancestor (for example, org.apache.kafka.connect as opposed to a classname) will update the levels of all child classes. Any levels previously set by this API will also be overridden. 

Code Block
languagebash
$ curl -Ss -X PUT '{"level": "TRACE"}' http://localhost:8083/admin/loggers/org.apache.kafka.connect
{
  modified: [
    ...
    "org.apache.kafka.connect.runtime.WorkerSinkTask",
   no output

Configuration Changes

 "org.apache.kafka.connect.runtime.WorkerSourceTask",
    ...
  ]
}

The above call returns org.apache.kafka.connect.runtime.WorkerSinkTask and org.apache.kafka.connect.runtime.WorkerSourceTask because they fall under the specified ancestor. If no name parameter is present, this API will set the log level of the root logger.

Configuration Changes

In addition, a new configuration property admin.listeners will be provided to specify which listener to use for the /admin endpoint. An additional configuration property will be used to control how the admin endpoint is made available.

Configuration NameDescriptionDefault BehaviorDomain
admin.listenersControl where the admin endpoint will be made available.the endpoint will be added to the rest of Connect's existing endpoints 

List of comma-separated URIs the REST API will listen on.
An empty or blank string will disable this feature.
Default behavior is to use the normal listener (default port 8083).

admin.listeners.https.Prefix for SSL settings when using HTTPS Look at Connect REST docs for a list of supported configs that  with this prefix.Look at Connect REST docs for a list of supported configs that can go with this prefix.

...

  • A /admin endpoint that can be configured to be attached to a different listener than the existing Connect endpoints.
  • The /admin/loggers endpoint that be used to modify log levels.
  • A new configuration property in WorkerConfig to enable/disable the /admin endpoint along with optionally configuring any HTTPS listeners if needed.

Log level changes are not persisted across worker restarts. These changes also only apply to the worker that receives the PUT request described above. 

Compatibility, Deprecation, and Migration Plan

...