Set service setting "LogNamespace" via snap.yaml

Hello community,

I am looking for a possibility to set the systemd service setting LogNamespace= (details see https://man.archlinux.org/man/systemd.exec.5.en) for a service created by snap via snap.yaml (snapcraft.yaml).

I found something similar in the forum (https://forum.snapcraft.io/t/how-to-customize-systemd-service-created-by-snapd/18397) with the note on command-chain. But how must this look in detail in snap.yaml?

Thank you in advance.

one thing to note is that all snaps typically write log entries prefixed with <snapname>.<servicename>, you might be able to filter based on this …

If you really need namespaced logging you should first of all file a bug against snapd so that a LogNamespace setting gets added to the daemon: handling eventually …

regarding the command-chain, a command-chain script needs to be created and installed somewhere in your snap (you can use a separate part for this if needed) and then called from the command-chain: entry in the snapcraft.yaml…

while you can not modify the LogNamespace entry with this, you should be able to use logger like:

#! /bin/sh

exec $@ | logger -t "foo"
1 Like