Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document or implement multi-line logging via stdout #5188

Closed
1 of 2 tasks
bryanburgers opened this issue Jan 30, 2017 · 2 comments
Closed
1 of 2 tasks

Document or implement multi-line logging via stdout #5188

bryanburgers opened this issue Jan 30, 2017 · 2 comments
Labels
already-implemented journal RFE 🎁 Request for Enhancement, i.e. a feature request

Comments

@bryanburgers
Copy link

Submission type

  • Bug report
  • Request for enhancement (RFE)

NOTE: Do not submit anything other than bug reports or RFEs via the issue tracker!

systemd version the issue has been seen with

systemctl --version
systemd 229
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD-IDN

NOTE: Do not submit bug reports about anything but the two most recently released systemd versions upstream!

Used distribution

Ubuntu 16.04

Request for enhancement

In new style daemons, the recommendation for logging is

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.

@bryanburgers
Copy link
Author

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.

@poettering
Copy link
Member

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.

@poettering poettering added already-implemented journal RFE 🎁 Request for Enhancement, i.e. a feature request labels Feb 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
already-implemented journal RFE 🎁 Request for Enhancement, i.e. a feature request
Development

No branches or pull requests

2 participants