Skip to main content
Topic: [SOLVED] pcsclite-openrc: why log to stdout? (Read 1146 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] pcsclite-openrc: why log to stdout?

I successfully installed pcsclite-openrc and everything works well with my yubikey. However, since I only have newbie experience with openrc from one gentoo installation in the past, I struggle with the logging of some daemons such as pcscd. Somehow the daemon is configured to log to stdout with the -f flag:

/etc/init.d/pcscd
Code: [Select]
command_args="${EXTRA_OPTS} -f"

Now I am a newbie when it comes to openrc and logging systems such as syslog-ng. I just found out about supervise-daemon in the gentoo openrc wiki: https://wiki.gentoo.org/wiki/OpenRC/supervise-daemon. This kind of explains why the -f flag is used, but how do I access logs from stdout? The wiki states:

Quote
Any terminal output sent by the daemon process to stdout and stderr can be caught by the supervisor, and then sent to the system logger [...]

I do not find any logs from pcscd in /var/log/messages.log, other than it being started by the supervisor. What do I need to do to get it to log via syslog-ng?  Is it about the loglevel? I'm not sure what to do.

Re: pcsclite-openrc: why log to stdout?

Reply #1
Change /etc/init.d/pcscd to contain this line:
Code: [Select]
supervise_daemon_args="--stdout /var/log/yourlogfile"

Re: pcsclite-openrc: why log to stdout?

Reply #2
Change /etc/init.d/pcscd to contain this line:
Code: [Select]
supervise_daemon_args="--stdout /var/log/yourlogfile"


Thank you for your reply, that's good to know! Any place where I can find this documented?

I'm still confused though about the documentation I quoted, specifically "can be caught by the supervisor, and then sent to the system logger". Your example logs directly to the file -- any way I can somehow send it through syslog? I thought the point of using syslog is that I do not have to redirect output to specific files.

Re: pcsclite-openrc: why log to stdout?

Reply #3
Code: [Select]
-f, --foreground
              Runs pcscd in the foreground and sends log messages to stderr instead of syslog(3)
This is hardcoded to pcscd. OTOH, supervise-daemon needs '-f' in order to supervise pcscd. I can't test it as I don't have the hardware, but in my syslog I'm getting a line from pcscd:
"pcscd[10099]: debuglog.c:299:DebugLogSetLevel() debug level=debug"
You can use logger(1) to redirect anything to syslog, there are thousands of howtos on the internet.

 

Re: pcsclite-openrc: why log to stdout?

Reply #4
Quote
This is hardcoded to pcscd. OTOH, supervise-daemon needs '-f' in order to supervise pcscd

I see, so the stdout log is kind of an unwanted side effect of running pcscd in the foreground. I would like to log to syslog in foreground, but I guess that is the design choice of pcscd. I'm comfortable with working around this though.

Quote
You can use logger(1) to redirect anything to syslog, there are thousands of howtos on the internet.

Thanks, that is one part of the solution. But I was more concerned of how to log with a command like `logger` as opposed to a log file. `--stdout` expects a file argument, so that particular flag does not work for me.

I found the solution in a github issue, for anyone that is interested: https://github.com/OpenRC/openrc/issues/127#issuecomment-398129031

Checking the man page of `start-stop-daemon` reveals that the flag for supervise_daemon that allows logging to another process is `--stdout-logger/--stderr-logger`. Using the `logger` command as an argument for this flag works for me.,

Thanks for pointing me in the right direction!  A lot to learn working without systemd/journald :)

EDIT: Wrong, I mixed up start-stop-daemon with supervise daemon; I thought they have the same command line arguments. Unmarked the thread as solved, as I am again not sure how to achieve what I am aiming for.

EDIT 2:  Marked as solved again. This is my final solution:

Code: [Select]
output_logger_arg="--stdout-logger /usr/bin/logger"