How to write init.d script log messages to disk?

9,744

It looks like the solution is to install bootlogd and put

BOOTLOGD_ENABLE=yes

in /etc/default/bootlogd.

References:

Share:
9,744

Related videos on Youtube

Jez
Author by

Jez

Long-time coder, with some interest in French and Philosophy. I sometimes hang out in the English Language & Usage chatroom. Check out my Firefox addons! :-)

Updated on September 18, 2022

Comments

  • Jez
    Jez over 1 year

    I'm running Debian wheezy. Many scripts in /etc/init.d/ use various logging functions defined in the Linux Standard Base, like log_success_msg and log_warning_msg. The LSB documentation seems a bit ambiguous as to exactly what these functions should do:

    The log_success_msg function shall cause the system to write a success message to an unspecified log file. The format of the message is unspecified. The log_success_msg function may also write a message to the standard output.

    However, I guess this is interpreted as meaning that the functions can either write to a log file or just write to standard output. It seems that on Debian at least, it just causes a message to be written to standard output. My suspicions were confirmed when I checked out the file defining these functions, /lib/lsb/init-functions - it just calls echo to display any log message.

    This is not helpful behaviour. Text written on boot to standard output disappears shortly after boot is complete, and may well scroll off the top of the screen in any case. Surely it would be far more helpful if these messages were actually stored in a log file; in fact I don't even see the point of logging anything via these functions if they are only going to go to standard output.

    Is there any way to get these logs going to a file? Can anyone enlighten me as to why you would bother "logging" anything only to standard output? What helpful function does it serve?

    • Batfan
      Batfan almost 12 years
      My reading of that is that logging the message to disk is mandatory, and repeating it to stdout is an optional extra. If you're right about the Debian behaviour, it looks to me as if Debian is not compliant.