svlogd(8)
β¨ svlogd(8) β¨
okay bestie, sit down, hydrate, because this is svlogd from the System Manager's Manual, and she is the logging daemon of the runit world π
πΈ NAME πΈ
svlogd β runit's service logging daemon
π SYNOPSIS π
svlogd [-tttv] [-r c] [-R xyz] [-l len] [-b buflen] logs
π DESCRIPTION π
So logs is one or more arguments, and each one names a directory. That's the whole vibe.
svlogd just keeps reading log data from its standard input, like, forever, optionally filters those log messages, and writes everything out to one or more logs that it automatically rotates for you. No cap. π₯
Recent log files can automatically be handed off to an arbitrary processor program whenever they get rotated, and svlogd can also be told to alert selected log messages to standard error, and through udp.
svlogd runs until it sees end-of-file on standard input or gets sent a TERM signal β see the SIGNALS section below, bestie, it's giving very important π
π LOG DIRECTORY π
A log directory log contains some number of old log files, plus the current log file current. The old log files have a file name starting with @ followed by a precise timestamp (see the daemontools' tai64n program), and that timestamp is telling you when current was rotated and renamed to this file. iconic behaviour, honestly π°οΈ
A log directory additionally contains the lock file lock, maybe state and newstate, and optionally the file config. svlogd creates necessary files if they don't exist β she's not gonna make you do it yourself πββοΈ
If svlogd has trouble opening a log directory, it prints a warning, and ignores this log directory. If svlogd is unable to open all log directories given at the command line, it exits with an error. This can happen on start-up or after receiving a HUP signal. so like, heads up π«Ά
π¦ LOG FILE ROTATION π¦
svlogd appends selected log messages to the current log file. If current has size bytes or more (or there is a new-line within the last len of size bytes), or is older than a specified amount of time, current is rotated:
svlogd closes current, changes permission of current to 0755, renames current to @timestamp.s, and starts with a new empty current. If svlogd sees num or more old log files in the log directory, it removes the oldest one. Note that this doesn't decrease the number of log files if there are already more than num log files β this must be done manually, e.g. for keeping 10 log files:
ls -1 \@* |sort |sed -ne '10,$p' |xargs rm
β¨ little reminder bestie: if you've already got more than num log files hanging around, rotation alone will not slim that down. you gotta do that yourself, manually, with the command above π
π§ PROCESSOR π§
If svlogd is told to process recent log files, it saves current to @timestamp.u, feeds @timestamp.u through sh -c "processor" and writes the output to @timestamp.t. If the processor finishes successfully, @timestamp.t is renamed to @timestamp.s, and @timestamp.u is deleted; otherwise @timestamp.t is deleted and the processor is started again. svlogd also saves any output that the processor writes to file descriptor 5, and makes that output available on file descriptor 4 when running processor on the next log file rotation.
A processor is run in the background. If svlogd sees a previously started processor still running when trying to start a new one for the same log, it blocks until the currently running processor has finished successfully. Only the HUP signal works in that situation. Note that this may block any program feeding its log data to svlogd. π blocking is real, fr fr
π CONFIG π
On startup, and after receiving a HUP signal, svlogd checks for each log directory log if the configuration file log/config exists, and if so, reads the file line by line and adjusts configuration for log as follows:
If the line is empty, or starts with a #, it is ignored. A line of the form
ssizeβ sets the maximum file size ofcurrentwhensvlogdshould rotate the current log file tosizebytes. Default is1000000. Ifsizeis zero,svlogddoesn't rotate log files. You should setsizeto at least (2 * len). πnnumβ sets the number of old log filessvlogdshould maintain tonum. Ifsvlogdsees more thatnumold log files inlogafter log file rotation, it deletes the oldest one. Default is10. Ifnumis zero,svlogddoesn't remove old log files.Nminβ sets the minimum number of old log filessvlogdshould maintain tomin.minmust be less thannum. Ifminis set, andsvlogdcannot write tocurrentbecause the filesystem is full, and it sees more thanminold log files, it deletes the oldest one.ttimeoutβ sets the maximum age of the current log file whensvlogdshould rotate the current log file totimeoutseconds. Ifcurrentistimeoutseconds old, and is not empty,svlogdforces log file rotation.!processorβ tellssvlogdto feed each recent log file throughprocessor(see above) on log file rotation. By default log files are not processed.ua.b.c.d[:port]β tellssvlogdto transmit the firstlencharacters of selected log messages to the IP addressa.b.c.d, port numberport. Ifportisn't set, the default port for syslog is used (514).lencan be set through the-loption, see below. Ifsvlogdhas trouble sending udp packets, it writes error messages to the log directory.
β οΈ Attention: logging through udp is unreliable, and should be used in private networks only. like, only only. this is not a drill π¨
Ua.b.c.d[:port]β is the same as theuline above, but the log messages are no longer written to the log directory, but transmitted through udp only. Error messages fromsvlogdconcerning sending udp packages still go to the log directory.pprefixβ tellssvlogdto prefix each line to be written to the log directory, to standard error, or through UDP, withprefix.
If a line starts with a -, +, e, or E, svlogd matches the first len characters of each log message against pattern and acts accordingly:
-patternβ the log message is deselected.+patternβ the log message is selected.epatternβ the log message is selected to be printed to standard error.Epatternβ the log message is deselected to be printed to standard error.
Initially each line is selected to be written to log/current. Deselected log messages are discarded from log. Initially each line is deselected to be written to standard err. Log messages selected for standard error are written to standard error.
β PATTERN MATCHING β
svlogd matches a log message against the string pattern as follows:
pattern is applied to the log message one character by one, starting with the first. A character not a star (*) and not a plus (+) matches itself. A plus matches the next character in pattern in the log message one or more times. A star before the end of pattern matches any string in the log message that does not include the next character in pattern. A star at the end of pattern matches any string.
Timestamps optionally added by svlogd are not considered part of the log message. bye π not relevant here.
An svlogd pattern is not a regular expression. no ma'am, it is not regex, do not come at her with regex energy π For example consider a log message like this
2005-12-18_09:13:50.97618 tcpsvd: info: pid 1977 from 10.4.1.14
The following pattern doesn't match
-*pid*
because the first star matches up to the first p in tcpsvd, and then the match fails because i is not s. To match this log message, you can use a pattern like this instead
-*: *: pid *
see? slay. the pattern understood the assignment π«Ά
π OPTIONS π
-tβ timestamp. Prefix each selected line with a precise timestamp (see the daemontools'tai64nprogram) when writing to log or to standard error.-ttβ timestamp. Prefix each selected line with a human readable, sortable UTC timestamp of the formYYYY-MM-DD_HH:MM:SS.xxxxxwhen writing to log or to standard error.-tttβ timestamp. Prefix each selected line with a human readable, sortable UTC timestamp of the formYYYY-MM-DDTHH:MM:SS.xxxxxwhen writing to log or to standard error.-r cβ replace.cmust be a single character. Replace non-printable characters in log messages withc. Characters are replaced before pattern matching is applied.-R xyzβ replace charset. Additionally to non-printable characters, replace all characters found inxyzwithc(default_).-l lenβ line length. Pattern matching applies to the firstlencharacters of a log message only. Default is1000.-b buflenβ buffer size. Set the size of the buffersvlogduses when reading from standard input and writing to logs tobuflen. Default is1024.buflenmust be greater thanlen. Forsvlogdinstances that process a lot of data in short time, the buffer size should be increased to improve performance.-vβ verbose. Print verbose messages to standard error.
π SIGNALS π
If svlogd is sent a HUP signal, it closes and reopens all logs, and updates their configuration according to log/config. If svlogd has trouble opening a log directory, it prints a warning, and discards this log directory. If svlogd is unable to open all log directories given at the command line, it exits with an error.
If svlogd is sent a TERM signal, or if it sees end-of-file on standard input, it stops reading standard input, processes the data in the buffer, waits for all processor subprocesses to finish if any, and exits 0 as soon as possible.
If svlogd is sent an ALRM signal, it forces log file rotation for all logs with a non empty current log file. β° girly pops off on schedule, periodt.
π SEE ALSO π
sv(8), runsv(8), chpst(8), runit(8), runit-init(8), runsvdir(8), runsvchdir(8)
π AUTHOR π
Gerrit Pape <pape@smarden.org>
and that's the whole page bestie!! πβ¨ she's svlogd(8) from the System Manager's Manual β go forth, log responsibly, rotate iconically, and remember: no cap, only @timestamp ππ¦π
π¦ where this page comes from
- alpine 3.24: runit-doc 2.3.1-r0 Β· BSD
- nixpkgs unstable: runit 2.3.1
- ubuntu stonking: runit 2.3.1-5ubuntu1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms