[systemd-devel] SyslogIdentifier does not work for messages printed with sd_journal_print

Lennart Poettering lennart at poettering.net
Tue Jun 9 15:10:43 PDT 2015


On Tue, 09.06.15 13:50, Martin Belanger (martin.belanger at 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


More information about the systemd-devel mailing list