view mod_log_json/README.markdown @ 4210:a0937b5cfdcb

mod_invites_page: Remove preauth URI button This button is incompatible with the majority of XMPP clients around, yet based on feedback from users, many are drawn to click it when they have any XMPP client installed already. In the case where the user already has software installed, we would prefer them to select it from the software list so they can follow the setup process suited to their specific client (we already track which software supports preauth URIs). If their client is not listed, they can still use the manual registration link instead.
author Matthew Wild <mwild1@gmail.com>
date Fri, 16 Oct 2020 11:03:38 +0100
parents bc865568ff02
children 4356088ad675
line wrap: on
line source

---
summary: JSON Log Sink
---

Conifiguration
==============

Here we log to `/var/log/prosody/prosody.json`:

``` {.lua}
log = {
  -- your other log sinks
  info = "/var/log/prosody/prosody.log"
  -- add this:
  { to = "json", filename = "/var/log/prosody/prosody.json" };
}
```

## UDP

Alternatively, it can send logs via UDP:

```lua
log = {
  { to = "json", udp_host = "10.1.2.3", udp_port = "9999" };
}
```

Format
======

JSON log files consist of a series of `\n`-separated JSON objects,
suitable for mangling with tools like
[`jq`](https://stedolan.github.io/jq/).

Example (with whitespace and indentation for readability):

``` {.json}
{
   "args" : [],
   "datetime" : "2019-11-03T13:38:28Z",
   "level" : "info",
   "message" : "Client connected",
   "source" : "c2s55f267f5b9d0"
}
{
   "args" : [
      "user@example.net"
   ],
   "datetime" : "2019-11-03T13:38:28Z",
   "level" : "debug",
   "message" : "load_roster: asked for: %s",
   "source" : "rostermanager"
}
```

`datetime`
:   [XEP-0082]-formatted timestamp.

`source`
:   Log source, usually a module or a connected session.

`level`
:   `debug`, `info`, `warn` or `error`

`message`
:   The log message in `printf` format. Combine with `args` to get the
    final message.

`args`
:   Array of extra arguments, corresponding to `printf`-style `%s`
    formatting in the `message`.