Log block (UnrealIRCd 6)

From UnrealIRCd documentation wiki
Jump to navigation Jump to search

In UnrealIRCd 6 the log block is used to log server messages to log files but also to decide which messages get sent to which snomasks (server notices). It is normal to have several log blocks.

If you have no log block that logs to disk then UnrealIRCd will by default log everything to ircd.log. Logging to disk is available in standard text format, but also in json format.

Syntax[edit]

log {
        source {
                <source1>;
                <source2>;
                ...
        };
        destination {
                // For logging to disk:
                file "ircd.log" {
                        maxsize 100M; /* optional */
                        type text; /* either 'text' or 'json' */
                };
                // For logging to snomask:
                snomask X;
                // For forwarding:
                remote;
        };
};

source[edit]

Here you select the log sources you want to log. This can be:

  • A subsystem, like: oper
  • A log level severity, like: debug
  • An event id, like: LINK_CONNECTING

Or a combination of the above, eg link.LINK_CONNECTING. You can also use negative matchers by use of an exclamation mark (!), eg: !link.LINK_CONNECTING.

See Log sources for a full list of subsystems and event ids.

Finally, there are also two special log sources:

  • all: this includes everything
  • nomatch: this includes anything that is not matched elsewhere. It should only be used for snomask s, as is done in conf/snomasks.default.conf. End-users should not change/use it.

destination[edit]

Here you specify what needs to be done with the log messages selected in source earlier.

destination::file[edit]

The filename specifies where to log to. Examples:

  • ircd.log: a literal filename
  • ircd.%Y-%m-%d.log: a filename with strftime formatting. This example will give you a new log file for every day such as: ircd.2020-01-31.log.
  • /var/log/unrealircd/ircd.log: a full path (NOTE: be sure UnrealIRCd can write to the directory)

It also has the following options:

  • maxsize: a maximum size of the log file. When the log file reaches this limit then log file will be renamed to name-of-log-file.old (overwriting any previous such .old file). You can use K/M/G to specify kilobytes/megabytes/gigabytes.
  • type: the logging output type. Use text for human readable text, or json for machine readable output, see JSON logging.

destination::syslog[edit]

If you want to log to *NIX syslog.

destination::snomask[edit]

This specifies to which snomask the messages should go. This should be a single letter.

destination::remote[edit]

This means the log message should be forwarded to all other servers. This is used in conf/snomasks.default.conf so things like link errors and oper-ups can be seen network-wide. End-users probably don't need to change/use this. Important: if you use this incorrectly, you may see duplicate server notices.

Example[edit]

Log all messages to disk[edit]

This simply logs all messages to disk in a human readable way:

log {
        source {
                !debug;
                all;
        }
        destination {
                file "ircd.log" { maxsize 100M; }
        }
}

Log all messages to disk in JSON format[edit]

This uses the JSON logging format. This is easier to parse by machines (external programs):

log {
        source {
                all;
        }
        destination {
                file "ircd.json.log" { maxsize 100M; type json; }
        }
}

Log to an snomask[edit]

This sends all log messages regarding local client connects and disconnects to the +c snomask (this is already done by default in conf/snomasks.default.conf):

/* Local client connects snomask - 'c' */
log {
        source {
                connect.LOCAL_CLIENT_CONNECT;
                connect.LOCAL_CLIENT_DISCONNECT;
        }
        destination {
                snomask c;
        }
}

You are free to create new snomasks with your own sources that you select on.