[systemd-devel] How to print debug printf messages when we login using telnet

Mantas Mikulėnas grawity at gmail.com
Wed Feb 27 11:36:33 UTC 2019


On Wed, Feb 27, 2019 at 12:49 PM Dhananjay Patil <Dhananjay.Patil at ltts.com>
wrote:

> Dear All,
>
> We successfully login using telnet on board.
>
> Our application start as systemd service in order to start at boot time.
>
> We define service as follow:
>
> [Unit]
>
> Description=Initmyapplication
>
>
>
> [Service]
>
> ExecStart=/usr/bin/myapplication &
>

The '&' is useless; ExecStart does not accept shell syntax, so all this is
doing is passing a literal "&" in the program's argv. All services are
already "in background" by definition.


> Our application have some debug messages implemented using printf.
>
> After completing login process using telnet those printf are not visible
> on telnet.
>

By default, services' output goes to the system log (journal or syslog).
You should be able to find them in `systemctl status myapp` or `journalctl
-b -u myapp`. (In recent systemd versions, you can also redirect the output
to a file.)

Note that libc buffers stdout when writing to files or pipes, which can
cause the printf output to be delayed. Make sure the application calls
fflush(stdout) after every debug printf, or use setlinebuf(stdout) on
application startup to switch to line-buffered mode.

-- 
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190227/1d4d278a/attachment.html>


More information about the systemd-devel mailing list