39f0158837c2b0b5ff6f7aab8f973fb1d21c5952
[oweals/busybox.git] / docs / logging_and_backgrounding.txt
1         Logging and backgrounding
2
3 By default, bb_[p]error_msg[_and_die] messages go to stderr,
4 and of course, usually applets do not auto-background. :)
5
6 Historically, daemons and inetd services are different.
7
8 Busybox is trying to provide compatible behavior, thus if an applet
9 is emulating an existing utility, it should mimic it. If utility
10 auto-backgrounds itself, busybox applet should do the same.
11 If utility normally logs to syslog, busybox applet should do
12 the same too.
13
14 However, busybox should not needlessly restrict the freedom
15 of the users. And users have different needs and different preferences.
16 Some might like logging everything from daemons to syslog.
17 Others prefer running stuff under runsv/svlogd and thus would like
18 logging to stderr and no daemonization.
19
20 To help with that, busybox applets should have options to override
21 default behavior, whatever that is for a given applet.
22
23
24 Current sutiation is a bit of a mess:
25
26 acpid - auto-backgrounds unless -d
27 crond - auto-backgrounds unless -f, logs to syslog unless -d or -L.
28     option -d logs to stderr, -L FILE logs to FILE
29 devfsd - (obsolete)
30 dnsd - option -d makes it auto-background and log to syslog
31 fakeidentd - inetd service. Auto-backgrounds and logs to syslog
32     if no -f and no -i and no -w (-i is "inetd service" flag,
33     -w is "inetd-wait service" flag)
34 ftpd - inetd service. Logs to syslog always, with -v logs to strerr too
35 httpd - auto-backgrounds unless -f or -i
36     (-i is "inetd service" flag)
37 inetd - auto-backgrounds unless -f, logs to syslog unless -e
38 klogd - auto-backgrounds unless -n
39 syslogd - auto-backgrounds unless -n
40 telnetd - auto-backgrounds unless -f or -i
41     (-i is "inetd service" flag)
42 udhcpc - auto-backgrounds unless -f after lease is obtained,
43     option -b makes it background sooner (when lease attempt
44     fails and retries start),
45     after backgrounding it stops logging to stderr;
46     logs to stderr, but option -S makes it log *also* to syslog
47 udhcpd - auto-backgrounds and do not log to stderr unless -f,
48     otherwise logs to stderr, but option -S makes it log *also* to syslog
49 zcip - auto-backgrounds and logs *also* to syslog unless -f
50
51 miscutils/crond.c:            logmode = LOGMODE_SYSLOG;
52 networking/dnsd.c:            logmode = LOGMODE_SYSLOG;
53 networking/ftpd.c:            logmode = LOGMODE_SYSLOG;
54 networking/ftpd.c:            logmode |= LOGMODE_SYSLOG;
55 networking/inetd.c:           logmode = LOGMODE_SYSLOG;
56 networking/isrv_identd.c:     logmode = LOGMODE_SYSLOG;
57 networking/telnetd.c:         logmode = LOGMODE_SYSLOG;
58 networking/udhcp/dhcpc.c:     logmode = LOGMODE_NONE;
59 networking/udhcp/dhcpc.c:     logmode |= LOGMODE_SYSLOG;
60 networking/udhcp/dhcpc.c:     logmode &= ~LOGMODE_STDIO;
61 networking/udhcp/dhcpd.c:     logmode = LOGMODE_NONE;
62 networking/udhcp/dhcpd.c:     logmode |= LOGMODE_SYSLOG;
63 networking/zcip.c:            logmode |= LOGMODE_SYSLOG;
64
65
66 These daemons seem to never auto-background/log to syslog:
67
68 lpd - inetd service. Has nothing to log so far, though
69 dhcprelay - standard behavior
70 inotifyd - standard behavior
71 runsv - standard behavior
72 runsvdir - standard behavior
73 svlogd - standard behavior
74 tcpsvd, udpsvd - standard behavior
75 tftpd - standard behavior
76
77
78 Non-daemons (seems to be use syslog for a good reason):
79
80 networking/nameif.c:          logmode |= LOGMODE_SYSLOG;
81 loginutils/chpasswd.c:        logmode = LOGMODE_BOTH;
82 loginutils/chpasswd.c:        logmode = LOGMODE_STDIO;
83 loginutils/getty.c:           logmode = LOGMODE_BOTH;
84 loginutils/getty.c:           logmode = LOGMODE_NONE;
85 loginutils/passwd.c:          logmode = LOGMODE_STDIO;
86 loginutils/passwd.c:          logmode = LOGMODE_BOTH;
87 loginutils/sulogin.c:         logmode = LOGMODE_SYSLOG; (used if stdio isn't a tty)
88 loginutils/sulogin.c:         logmode = LOGMODE_BOTH;
89 util-linux/mount.c:           logmode = LOGMODE_SYSLOG; (used in a backgrounded NFS mount helper)