Here we log to /var/log/prosody/prosody.json:
log = {
-- your other log sinks
info = "/var/log/prosody/prosody.log"
-- add this:
{ to = "json", filename = "/var/log/prosody/prosody.json" };
}Alternatively, it can send logs via UDP:
log = {
{ to = "json", udp_host = "10.1.2.3", udp_port = "9999" };
}JSON log files consist of a series of \n-separated JSON
objects, suitable for mangling with tools like jq.
Example (with whitespace and indentation for readability):
{
"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"
}datetimesourceleveldebug, info, warn or
error
messageprintf format. Combine with
args to get the final message.
argsprintf-style
%s formatting in the message.
If desired, at the obvious expense of performance, the formatted
version of the string can be included in the JSON object by specifying
the formatted_as key in the logger config:
log = {
-- ... other sinks ...
{ to = "json", formatted_as = "msg_formatted", filename = "/var/log/prosody/prosody.json" };
}This will expose the formatted message in the JSON as separate
msg_formatted key. It is possible to override existing keys
using this (for example, the message key), but not
advisible.
With the plugin installer in Prosody 0.12 you can use:
sudo prosodyctl install --server=https://modules.prosody.im/rocks/ mod_log_json
For earlier versions see the documentation for installing 3rd party modules