{
  "$schema": "../rpc-schema-draft.json",
  "type": "object",
  "rpc": "getlog",
  "title": "Command to show recent logs.",
  "description": [
    "The **getlog** the RPC command to show logs, with optional log *level*."
  ],
  "categories": [
    "readonly"
  ],
  "request": {
    "required": [],
    "additionalProperties": false,
    "properties": {
      "level": {
        "type": "string",
        "enum": [
          "broken",
          "unusual",
          "info",
          "debug",
          "trace",
          "io"
        ],
        "description": [
          "A string that represents the log level."
        ],
        "default": "*info*"
      }
    }
  },
  "response": {
    "required": [
      "created_at",
      "bytes_used",
      "bytes_max",
      "log"
    ],
    "additionalProperties": false,
    "properties": {
      "created_at": {
        "type": "string",
        "description": [
          "UNIX timestamp with 9 decimal places, when logging was initialized."
        ]
      },
      "bytes_used": {
        "type": "u32",
        "description": [
          "The number of bytes used by logging records."
        ]
      },
      "bytes_max": {
        "type": "u32",
        "description": [
          "The bytes_used values at which records will be trimmed ."
        ]
      },
      "log": {
        "type": "array",
        "items": {
          "type": "object",
          "required": [
            "type"
          ],
          "additionalProperties": true,
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "SKIPPED",
                "BROKEN",
                "UNUSUAL",
                "INFO",
                "DEBUG",
                "TRACE",
                "IO_IN",
                "IO_OUT"
              ]
            }
          },
          "allOf": [
            {
              "if": {
                "additionalProperties": true,
                "properties": {
                  "type": {
                    "enum": [
                      "SKIPPED"
                    ]
                  }
                }
              },
              "then": {
                "additionalProperties": false,
                "required": [
                  "num_skipped"
                ],
                "properties": {
                  "type": {},
                  "num_skipped": {
                    "type": "u32",
                    "description": [
                      "Number of unprinted log entries (deleted or below *level* parameter)."
                    ]
                  }
                }
              }
            },
            {
              "if": {
                "additionalProperties": true,
                "properties": {
                  "type": {
                    "enum": [
                      "BROKEN",
                      "UNUSUAL",
                      "INFO",
                      "DEBUG",
                      "TRACE"
                    ]
                  }
                }
              },
              "then": {
                "additionalProperties": false,
                "required": [
                  "time",
                  "source",
                  "log"
                ],
                "properties": {
                  "type": {},
                  "time": {
                    "type": "string",
                    "description": [
                      "UNIX timestamp with 9 decimal places after **created_at**."
                    ]
                  },
                  "source": {
                    "type": "string",
                    "description": [
                      "The particular logbook this was found in."
                    ]
                  },
                  "log": {
                    "type": "string",
                    "description": [
                      "The actual log message."
                    ]
                  },
                  "node_id": {
                    "type": "pubkey",
                    "description": [
                      "The peer this is associated with."
                    ]
                  }
                }
              }
            },
            {
              "if": {
                "additionalProperties": true,
                "properties": {
                  "type": {
                    "enum": [
                      "IO_IN",
                      "IO_OUT"
                    ]
                  }
                }
              },
              "then": {
                "additionalProperties": false,
                "required": [
                  "time",
                  "source",
                  "log"
                ],
                "properties": {
                  "type": {},
                  "time": {
                    "type": "string",
                    "description": [
                      "Seconds after **created_at**, with 9 decimal places."
                    ]
                  },
                  "source": {
                    "type": "string",
                    "description": [
                      "The particular logbook this was found in."
                    ]
                  },
                  "log": {
                    "type": "string",
                    "description": [
                      "The associated log message."
                    ]
                  },
                  "node_id": {
                    "type": "pubkey",
                    "description": [
                      "The peer this is associated with."
                    ]
                  },
                  "data": {
                    "type": "hex",
                    "description": [
                      "The IO which occurred."
                    ]
                  }
                }
              }
            }
          ]
        }
      }
    }
  },
  "errors": [
    "On failure, one of the following error codes may be returned:",
    "",
    "- -32602: Error in given parameters."
  ],
  "author": [
    "Vincenzo Palazzo [vincenzo.palazzo@protonmail.com](mailto:vincenzo.palazzo@protonmail.com) wrote the initial version of this man page,",
    "but many others did the hard work of actually implementing this rpc command."
  ],
  "resources": [
    "Main web site: [https://github.com/ElementsProject/lightning](https://github.com/ElementsProject/lightning)"
  ],
  "examples": [
    {
      "request": {
        "id": "example:getlog#1",
        "method": "getlog",
        "params": {
          "level": "unusual"
        }
      },
      "response": {
        "created_at": 1738000000,
        "bytes_used": 1630000,
        "bytes_max": 10485760,
        "log": [
          {
            "type": "SKIPPED",
            "num_skipped": 144
          },
          {
            "type": "UNUSUAL",
            "time": "71.800000000",
            "source": "plugin-bookkeeper",
            "log": "topic 'utxo_deposit' is not a known notification topic"
          },
          {
            "type": "UNUSUAL",
            "time": "72.800000000",
            "source": "plugin-bookkeeper",
            "log": "topic 'utxo_spend' is not a known notification topic"
          },
          {
            "type": "SKIPPED",
            "num_skipped": 147
          },
          {
            "type": "UNUSUAL",
            "time": "74.800000000",
            "node_id": "nodeid010101010101010101010101010101010101010101010101010101010101",
            "source": "chan#1",
            "log": "No peer channel with scid=228x1x1"
          }
        ]
      }
    }
  ]
}
