I have a small service written in C on Debian.
This service automatically starts with Linux and does some file operations and other things as expected.
The service prints some informational messages and also error situations to standard output. This is visible in a console window when I run the binary from console not as a service.
The only thing I didn't manage to accomplish so far is write its output into the journal, when the binary is run as a service.
I went through all search hits I found, I am querying the journal as root and I see system messages starting/stopping the service, but nothing that the service binary prints.
I simply print with printf("hey this should appear in the journal"); - but there is nothing to see in the journal.
According to what is explained everywhere, all output of a service should automatically be directed to the journal, right?
What could I be missing so that this doesn't happen?
Edit
I found special functions to call for logging, but actually I like the idea to get standard output automatically either on the console or in the journal, depending on how I run the binary.
I tried a bash script service and found it writes echo messages into the journal as expected.
systemd-journalfrom C++ program or How can I send a message to thesystemdjournal?printf("...");- but there is nothing to see in the journal.", I would expect aprintkthere if I remember it right.printkis used in the kernel, it’s not available in user land.