A daemon process doesn't have stdout at all.
Not true. If one's dæmons are being managed by one of the daemontools family of toolsets (https://unix.stackexchange.com/a/179798/5132), then the dæmon will have inherited an open standard output file descriptor, for a pipe that connects it to a logging service. If one is using systemd, then (in the default configuration) the the dæmon will have inherited an open standard output file descriptor, for a socket that connects it to the systemd journal service.
In any case, you are conflating the
init.d script, which manages the dæmon, with the dæmon itself. With System V
rc and with systemd, the
init.d script merely causes the starting and stopping of the dæmon process proper. (In the System V
rc case it does this with helpers such as
start-stop-daemon. In the systemd case, it uses
systemctl to send commands over D-Bus RPC to process #1.) It isn't the dæmon process itself.
The standard output of the dæmon process isn't necessarily any relation at all to the standard output of the
init.d script. And it's the standard output of the latter that you are addressing with
log_daemon_msg. This shell function, and its relatives, print friendly messages from the dæmon management script, showing what the management script is doing as it attempts to enact dæmon control commands. They aren't being used in the dæmon itself.
Ironically, since daemon management is done differently with systemd, all of the
log_daemon_msg commands become irrelevant, since any management script that sources
/lib/lsb/init-functions ends up diverting all control commands to
How can I redirect the init logs to a system log file so that I can debug boot time issues?
You have a task. You've decided that a subtask of that task is somehow addressible with
log_daemon_msg, and here you are asking how to get
log_daemon_msg to do something that it wasn't designed to do. Concentrate upon your real question.
Ubuntu 14.04 uses upstart. That has an
/etc/init/rc.conf upstart job that provides backwards compatibility with System V
rc by actually running System V
rc whenever a runlevel event occurs. This job is listed in the upstart Cookbook and as you can see uses the
console output stanza.
As you can see from the Cookbook, with upstart — as well — dæmons (by default) inherit an open standard output file descriptor that is connected to upstart's per-job logging mechanism. Yet again, the notion that dæmons "don't have standard output" is wrong. The
/etc/init/rc.conf job uses the (non-default) option of connecting the standard output to the console. This of course also redirects the output of the various dæmon management scripts that System V
rc spawns, in its turn.
So if you want to log the output of your
/etc/init/rc.conf job, and all of the System V management scripts that it spawns, elsewhere, modify that job specification.
If you want to debug boot-time issues, then employ the mechanisms that are described in the upstart Cookbook (and also on the AskUbuntu Stack Exchange in several answers) for boot-time debugging.