Logging

Added in version 1.3.7.

The OctoPrint Logging plugin implements the log management functionality that was formerly part of the core application and adds features to configure logging levels for sub modules through the included settings dialog.

Logging plugin

Fig. 18 The settings dialog of the Logging plugin

API

Note

All log file management operations require admin rights.

Retrieve a list of available log files

GET /plugin/logging/logs

Retrieve information regarding all log files currently available and regarding the disk space still available in the system on the location the log files are being stored.

Returns a Logfile Retrieve response.

Example

GET /plugin/logging/logs HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
HTTP/1.1 200 OK
Content-Type: application/json

{
  "files" : [
    {
      "date" : 1393158814,
      "name" : "octoprint.log",
      "size" : 43712,
      "refs": {
        "resource": "http://example.com/plugin/logging/logs/octoprint.log",
        "download": "http://example.com/downloads/logs/octoprint.log"
      }
    },
    {
      "date" : 1392628936,
      "name" : "octoprint.log.2014-02-17",
      "size" : 13205,
      "refs": {
        "resource": "http://example.com/plugin/logging/logs/octoprint.log.2014-02-17",
        "download": "http://example.com/downloads/logs/octoprint.log.2014-02-17"
      }
    },
    {
      "date" : 1393158814,
      "name" : "serial.log",
      "size" : 1798419,
      "refs": {
        "resource": "http://example.com/plugin/logging/logs/serial.log",
        "download": "http://example.com/downloads/logs/serial.log"
      }
    }
  ],
  "free": 12237201408
}
Status Codes:
  • 200 OK – No error

  • 403 Forbidden – If the given API token did not have admin rights associated with it

Delete a specific logfile

DELETE /plugin/logging/logs/(path: filename)

Delete the selected log file with name filename.

Returns a 204 No Content after successful deletion.

Example Request

DELETE /plugin/logging/logs/octoprint.log.2014-02-17 HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
Parameters:
  • filename – The filename of the log file to delete

Status Codes:

Data model

Logfile Retrieve Response

Name

Multiplicity

Type

Description

files

0..*

Array of File information items

The list of requested files. Might be an empty list if no files are available

free

1

String

The amount of disk space in bytes available in the local disk space (refers to OctoPrint’s logs folder).

File information

Name

Multiplicity

Type

Description

name

1

String

The name of the file

size

1

Number

The size of the file in bytes.

date

1

Unix timestamp

The timestamp when this file was last modified.

refs

1

References

References relevant to this file

References

Name

Multiplicity

Type

Description

resource

1

URL

The resource that represents the file (e.g. for deleting)

download

1

URL

The download URL for the file

JS Client Library

OctoPrintClient.plugins.logging

Note

All methods here require that the used API token or the existing browser session has admin rights.

OctoPrintClient.plugins.logging.listLogs(opts)

Retrieves a list of log files.

See Retrieve a list of available log files for details.

Arguments:
  • opts (object()) – Additional options for the request

Returns Promise:

A jQuery Promise for the request’s response

OctoPrintClient.plugins.logging.deleteLog(path, opts)

Deletes the specified log path.

See Delete a specific log file for details.

Arguments:
  • path (string()) – The path to the log file to delete

  • opts (object()) – Additional options for the request

Returns Promise:

A jQuery Promise for the request’s response

OctoPrintClient.plugins.logging.downloadLog(path, opts)

Downloads the specified log file.

See OctoPrint.download() for more details on the underlying library download mechanism.

Arguments:
  • path (string()) – The path to the log file to download

  • opts (object()) – Additional options for the request

Returns Promise:

A jQuery Promise for the request’s response

Source Code

The source of the Logging plugin is bundled with OctoPrint and can be found in its source repository under src/octoprint/plugins/logging.