# phpman > man > svlogd(8)

[svlogd(8)](https://www.chedong.com/phpMan.php/man/svlogd/8/markdown)                              System Manager's Manual                             [svlogd(8)](https://www.chedong.com/phpMan.php/man/svlogd/8/markdown)



## NAME
       svlogd - runit's service logging daemon

## SYNOPSIS
       **svlogd** [-tttv] [-r _c_] [-R _xyz_] [-l _len_] [-b _buflen_] _logs_

## DESCRIPTION
       _logs_ consists of one or more arguments, each specifying a directory.

       **svlogd**  continuously reads log data from its standard input, optionally filters log messages,
       and writes the data to one or more automatically rotated _logs_.

       Recent log files can automatically be processed by an arbitrary processor program  when  they
       are  rotated,  and  **svlogd**  can 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 is sent a TERM signal, see below.

   **LOG** **DIRECTORY**
       A log directory _log_ contains some number of old log files, and the current log file  _current_.
       Old  log files have a file name starting with _@_ followed by a precise timestamp (see the dae‐
       montools' **tai64n** program), indicating when _current_ was rotated and renamed to this file.

       A log directory additionally contains the lock file _lock_, maybe _state_ and _newstate_,  and  op‐
       tionally the file _config_.  **svlogd** creates necessary files if they don't exist.

       If  **svlogd** has trouble opening a log directory, it prints a warning, and ignores this log di‐
       rectory.  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.

   **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 @_time__‐
       _stamp_.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

   **PROCESSOR**
       If **svlogd** is told to process recent log files, it saves _current_ to @_timestamp_.u, feeds @_time__‐
       _stamp_.u through ``sh -c "_processor_"'' and writes the output to @_timestamp_.t.  If the  _proces__‐
       _sor_  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 avail‐
       able 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 run‐
       ning _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.**


   **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 con‐
       figuration for _log_ as follows:

       If the line is empty, or starts with a ``#'', it is ignored.  A line of the form

       s_size_  sets  the  maximum file size of _current_ when **svlogd** should rotate the current log file
              to _size_ bytes.  Default is 1000000.  If _size_ is zero, **svlogd** doesn't rotate log files.
              You should set _size_ to at least (2 * _len_).

       n_num_   sets  the  number of old log files **svlogd** should maintain to _num_.  If **svlogd** sees more
              that _num_ old log files in _log_ after log file rotation, it deletes the oldest one.  De‐
              fault is 10.  If _num_ is zero, **svlogd** doesn't remove old log files.

       N_min_   sets  the  minimum number of old log files **svlogd** should maintain to _min_.  _min_ must be
              less than _num_.  If _min_ is set, and **svlogd** cannot write to _current_ because the filesys‐
              tem is full, and it sees more than _min_ old log files, it deletes the oldest one.

       t_timeout_
              sets the maximum age of the _current_ log file when **svlogd** should rotate the current log
              file to _timeout_ seconds.  If _current_ is _timeout_ seconds old, and is not empty,  **svlogd**
              forces log file rotation.

       !_processor_
              tells  **svlogd**  to  feed each recent log file through _processor_ (see above) on log file
              rotation.  By default log files are not processed.

       u_a.b.c.d[:port]_
              tells **svlogd** to transmit the first _len_ characters of selected log messages to  the  IP
              address  _a.b.c.d_, port number _port_.  If _port_ isn't set, the default port for syslog is
              used (514).  _len_ can be set through the -l option, see below.  If **svlogd**  has  trouble
              sending  udp  packets, it writes error messages to the log directory.  Attention: log‐
              ging through udp is unreliable, and should be used in private networks only.

       U_a.b.c.d[:port]_
              is the same as the _u_ line above, but the log messages are no longer written to the log
              directory,  but  transmitted  through udp only.  Error messages from **svlogd** concerning
              sending udp packages still go to the log directory.

       p_prefix_
              tells **svlogd** to prefix each line to be written to the log directory, to  standard  er‐
              ror, or through UDP, with _prefix_.

       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.

       e_pattern_
              the log message is selected to be printed to standard error.

       E_pattern_
              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 char‐
       acter  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.

       An **svlogd** pattern is not a regular expression.  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 *

## OPTIONS
### -t
              **tai64n** program) when writing to _log_ or to standard error.

### -tt
              the form YYYY-MM-DD_HH:MM:SS.xxxxx when writing to _log_ or to standard error.

### -ttt
              the form YYYY-MM-DDTHH:MM:SS.xxxxx when writing to _log_ or to standard error.

### -r
              sages with _c_.  Characters are replaced before pattern matching is applied.

### -R
              found in _xyz_ with _c_ (default ``_'').

### -l
              only.  Default is 1000.

### -b
              buffer  size.  Set the size of the buffer **svlogd** uses when reading from standard input
              and writing to _logs_ to _buflen_.  Default is 1024.  _buflen_ must  be  greater  than  _len_.
              For  **svlogd** instances that process a lot of data in short time, the buffer size should
              be increased to improve performance.

### -v

## SIGNALS
       If **svlogd** is sent a HUP signal, it closes and reopens all _logs_, and updates their  configura‐
       tion  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 read‐
       ing 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.

## SEE ALSO
       [sv(8)](https://www.chedong.com/phpMan.php/man/sv/8/markdown), [runsv(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown), [chpst(8)](https://www.chedong.com/phpMan.php/man/chpst/8/markdown), [runit(8)](https://www.chedong.com/phpMan.php/man/runit/8/markdown), [runit-init(8)](https://www.chedong.com/phpMan.php/man/runit-init/8/markdown), [runsvdir(8)](https://www.chedong.com/phpMan.php/man/runsvdir/8/markdown), [runsvchdir(8)](https://www.chedong.com/phpMan.php/man/runsvchdir/8/markdown)

       <http://smarden.org/runit/>

## AUTHOR
       Gerrit Pape <<pape@smarden.org>>



                                                                                           [svlogd(8)](https://www.chedong.com/phpMan.php/man/svlogd/8/markdown)
