2

when I execute command foo in console (ie tty1), the output is sent to the console.

daemon foo started successfully

When I execute the same command in virtual terminal (terminator), I see no output in the terminal, but the output is sent to syslog.

Why is this, and how can I control where the output is sent ?

I have an init startup script that executes command foo, and the output is sent to tty1. I would like to send the output to syslog instead (as if I had started the init script in virtual terminal, instead of in console)

4
  • Look at the source. Commented Aug 26, 2020 at 9:48
  • You are mixing up console and virtual terminal here.
    – JdeBP
    Commented Aug 26, 2020 at 11:11
  • @ Ipor Sircer - do you think this behavior is specific to my application, not a system wide behavior? Commented Aug 26, 2020 at 12:08
  • If your startup script is started from the /etc/rc* standard script on a recent Unix, then the output of your script will behave as you want: through syslog. Just try a reboot.
    – athena
    Commented Aug 31, 2020 at 12:54

1 Answer 1

3
+100

As you can read in the Debian man page for daemon, it vastly depends on how you implemented your daemon under which init system.

  • The SysV way (stdin/out/err connected to /dev/null)
  • The "New-style" way : (stdout/stderr directed to systemd-journald.service)

... 10.Instead of using the syslog() call to log directly to the system syslog service, a new-style daemon may choose to simply log to standard error via fprintf(), which is then forwarded to syslog by the init system ...

In this latter case, the behaviour you notice under your xterm is the normal way.

What the daemon outputs via fprintf (stdout / stderr) is then under the control of syslog.

Therefore, depending on your syslog configuration (as you find it in your syslog.conf file) and depending on the log level, what your daemon outputs will be ignored / appended to some particular file / echoed on the system console (your tty1), and never xterm.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .