You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
However, there is no direction on how to log an entry with newlines in it. If the newlines are printed normally, syslog will pick this up as independent log entries.
While it typically makes sense to have one line per log entry, there are certain cases (especially stack traces) where it makes sense to have multiple lines in a single message.
The request is to (1) either document how to do this in an appropriate location, or (2) implement the functionality to allow logging multiple lines in a single log entry when logging via stdout/stderr.
The text was updated successfully, but these errors were encountered:
Upon reading more documentation, systemd 231 introduced the JOURNAL_STREAM environment variable, so maybe the better option is to check if the application is connected to the journal and use sd_journal_print instead.
So, I am pretty sure, that if any fancier kind of logging shall take place, then the best option is to use sd_journal_print() and related calls instead. It permits passing all kinds of metadata, and also doing multiline log events.
And as you found out, we make it possible to detect whether stdout/stderr is connected to the journal these days, thus permitting an easy upgrade.
Hence, I think you can already do what you are looking for. Closing this, I hopt that's OK.
Submission type
NOTE: Do not submit anything other than bug reports or RFEs via the issue tracker!
systemd version the issue has been seen with
NOTE: Do not submit bug reports about anything but the two most recently released systemd versions upstream!
Used distribution
Request for enhancement
In new style daemons, the recommendation for logging is
However, there is no direction on how to log an entry with newlines in it. If the newlines are printed normally, syslog will pick this up as independent log entries.
While it typically makes sense to have one line per log entry, there are certain cases (especially stack traces) where it makes sense to have multiple lines in a single message.
The request is to (1) either document how to do this in an appropriate location, or (2) implement the functionality to allow logging multiple lines in a single log entry when logging via stdout/stderr.
The text was updated successfully, but these errors were encountered: