if a app snap is run deamon, how to see the syslog of running app snap?
If the app is a service, you can either use snap logs <snap>
or directly call journalctl like this: journalctl -u snap.<snap-name>.<svc-name>.service
.
thanks reply. i use snap logs is useful to see the snap logs.And i want to know where these logs save in system file?
The logs are collected and stored by systemd-journald
. You will need to consult the systemd documentation to find out the exact place where logs are stored. This should be a good starting point: https://www.freedesktop.org/software/systemd/man/journald.conf.html Usually it’s somewhere under /var/log/$(cat /etc/machine-id)/
.
thanks reply. below is In the /var/log/ files
Your system may be configured to store logs in different location. Try inspecting journald.conf to find out the location.
I check the journald.conf file don’t find the syslog location.
journald defaults to logging to a tmpfs ringbuffer in /run/log/journal
to make it log persistent you only need to create the dir /var/jog/journal
and it will automatically start writing log files there instead.
/var/jog/journal is read only system files
not here …
ogra@localhost:~$ ls /var/log/
btmp console-conf lastlog tallylog wtmp
ogra@localhost:~$ sudo mkdir /var/log/journal
ogra@localhost:~$ sudo reboot
Connection to 192.168.2.87 closed by remote host.
Connection to 192.168.2.87 closed.
ogra@acheron:~$ ssh 192.168.2.87
Welcome to Ubuntu Core 18 (GNU/Linux 5.3.0-1019-raspi2 armv7l)
* Ubuntu Core: https://www.ubuntu.com/core
* Community: https://forum.snapcraft.io
* Snaps: https://snapcraft.io
...
Please see 'snap --help' for app installation and updates.
Last login: Mon Mar 23 10:27:12 2020 from 192.168.2.48
ogra@localhost:~$ ls -l /var/log/journal/
total 4
drwxr-sr-x+ 2 root systemd-journal 4096 Mar 19 16:51 6c7abda527af422aa97ff92950470ed2
ogra@localhost:~$
By default, Ubuntu has journald set up not to persist logs, so they may well not be persisted in /var/log.
The configuration file is in: /etc/systemd/journald.conf
If it’s volatile it’s stored only very temporarily. If it’s auto, it might be volatile. It sounds as if you want “persistent”, then load the configuration with systemctl reload systemd-journald
.
Note, however, that journald log files are a binary format and not very human-friendly. The best way to read them is with journalctl, e.g. journalctl -f
for live updates, journalctl -n 100
for the last 100 lines and so on. You can filter by date range, service and so on.
For more configuration options you can read the manual here: https://www.freedesktop.org/software/systemd/man/journald.conf.html
there is no need to touch the configuration file, journald in all ubuntu installs is set up so it will automatically start logging to disk as soon as the /var/log/journal directory is created.
if using Ubuntu Core, there is a system option you can enable via:
snap set system.journal.persistent=true
(or via a gadget.yaml defaults:
entry)
That will create the directory without you needing explicit write access …
https://snapcraft.io/docs/system-options#heading--journal-persistent