Re: [systemd-devel] SyslogIdentifier does not work for messages printed with sd_journal_print
On Tue, 02.06.15 20:31, Martin Belanger (martin.belan...@cyaninc.com) wrote: I'm using systemd 219 (Ubuntu 15.04). I have three instances of a daemon running. I use SyslogIdentifier to give each of them a unique identifier (e.g. myproc-1, myproc-2, myproc-3). I also redirect stdout/stderr to the journal using StandardOutput=journal and StandardError=journal. I noticed that messages sent to the journal with printf (i.e. stdout) get the proper SYSLOG_IDENTIFIER. However, messages send to the journal with sd_journal_print() get the default SYSLOG_IDENTIFIER (i.e. the process name). I also tried sd_journal_send() and get the same result. Any thoughts as to why this is happening? SyslogIdentifier only really applies to stdout/stderr messages, not to native journal messages, which will not carry that id at all. The only reason the setting exists is because it's useful to set something there because stdout/stderr doesn't carry enough information for this, and because the same stdout/stderr stream can be shared among multiple processes it's difficult and misleading to automatically derive the identifier from them... Hence: I'd really prefer fi we didn't have that option at all, we justed added it, because it was difficult to do without... Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] SyslogIdentifier does not work for messages printed with sd_journal_print
Hi Lennart, I found a workaround. When looking at the source code for sd_journal_print(), I saw that SYSLOG_IDENTIFIER defaults to the string pointed to by program_invocation_short_name (defined in errno.h). So I simply create a new string with the text that I want to assign to SYSLOG_IDENTIFIER and I make program_invocation_short_name point to it. It may not be the prettiest fix, but it works for the daemons I'm instantiating. Thanks, Martin Martin Belanger Sr. Software Engineer[image: Cyan]1383 North McDowell Blvd. Petaluma, CA 94954M(707) 481-3392emartin.belan...@cyaninc.comwww.cyaninc.com[image: Facebook] http://www.facebook.com/CyanInc [image: LinkedIn] http://www.linkedin.com/company/cyan-inc?trk=hb_tab_compy_id_2171992 [image: Twitter] http://twitter.com/CyanNews On Tue, Jun 9, 2015 at 3:16 AM, Lennart Poettering lenn...@poettering.net wrote: On Tue, 02.06.15 20:31, Martin Belanger (martin.belan...@cyaninc.com) wrote: I'm using systemd 219 (Ubuntu 15.04). I have three instances of a daemon running. I use SyslogIdentifier to give each of them a unique identifier (e.g. myproc-1, myproc-2, myproc-3). I also redirect stdout/stderr to the journal using StandardOutput=journal and StandardError=journal. I noticed that messages sent to the journal with printf (i.e. stdout) get the proper SYSLOG_IDENTIFIER. However, messages send to the journal with sd_journal_print() get the default SYSLOG_IDENTIFIER (i.e. the process name). I also tried sd_journal_send() and get the same result. Any thoughts as to why this is happening? SyslogIdentifier only really applies to stdout/stderr messages, not to native journal messages, which will not carry that id at all. The only reason the setting exists is because it's useful to set something there because stdout/stderr doesn't carry enough information for this, and because the same stdout/stderr stream can be shared among multiple processes it's difficult and misleading to automatically derive the identifier from them... Hence: I'd really prefer fi we didn't have that option at all, we justed added it, because it was difficult to do without... Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] SyslogIdentifier does not work for messages printed with sd_journal_print
On Tue, 09.06.15 13:50, Martin Belanger (martin.belan...@cyaninc.com) wrote: Hi Lennart, I found a workaround. When looking at the source code for sd_journal_print(), I saw that SYSLOG_IDENTIFIER defaults to the string pointed to by program_invocation_short_name (defined in errno.h). So I simply create a new string with the text that I want to assign to SYSLOG_IDENTIFIER and I make program_invocation_short_name point to it. It may not be the prettiest fix, but it works for the daemons I'm instantiating. Ah, yes, if you want to set this from your process internally, then setting program_invocation_short_name is actually completely OK. I don't even think it's ugly in any way. It's the short identifier for the program used on GNU, and it's initialized by argv[0] but you can set it to anything you like. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] SyslogIdentifier does not work for messages printed with sd_journal_print
I'm using systemd 219 (Ubuntu 15.04). I have three instances of a daemon running. I use SyslogIdentifier to give each of them a unique identifier (e.g. myproc-1, myproc-2, myproc-3). I also redirect stdout/stderr to the journal using StandardOutput=journal and StandardError=journal. I noticed that messages sent to the journal with printf (i.e. stdout) get the proper SYSLOG_IDENTIFIER. However, messages send to the journal with sd_journal_print() get the default SYSLOG_IDENTIFIER (i.e. the process name). I also tried sd_journal_send() and get the same result. Any thoughts as to why this is happening? Thanks, Martin ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel