Change systemd’s binary logging to text logging in Sabayon Linux
September 20, 2014 4 Comments
systemd logs system messages in a binary file which the developers call a ‘journal’. However, if you would prefer system messages to be logged in a text file, here is how to do it for Sabayon Linux. The steps will probably be similar in other distributions.
1. See what log files currently exist in your installation:
# ls /var/log
anaconda btmp cups faillog kdm.log mysql portage sandbox tallylog Xorg.0.log
boot.log chrony entropy journal lastlog news samba spice-vdagentd wtmp Xorg.0.log.old
Notice that the traditional text log file /var/log/messages
is not present. The systemd binary log files are in a sub-directory of /var/log/journal/
:
# ls /var/log/journal
5d387e19d28644c5b24f06f8bc6e9b9c
# ls /var/log/journal/5d387e19d28644c5b24f06f8bc6e9b9c
system.journal user-1000.journal
2. Edit the file /etc/systemd/journald.conf
and change #Storage=auto
to Storage=none
# nano /etc/systemd/journald.conf
3. Install the system logger syslog-ng:
# equo install syslog-ng
If it’s not already installed, install the logrotate
package:
# equo install logrotate
4. Enable the service so that it starts the next time you boot:
# systemctl enable syslog-ng.service
ln -s '/usr/lib/systemd/system/syslog-ng.service' '/etc/systemd/system/syslog.service'
ln -s '/usr/lib/systemd/system/syslog-ng.service' '/etc/systemd/system/multi-user.target.wants/syslog-ng.service'
5. Start the service now:
# systemctl start syslog-ng.service
6. Check if the text log file /var/log/messages
has been created:
# ls /var/log
anaconda btmp cups faillog kdm.log messages news samba spice-vdagentd wtmp Xorg.0.log.old
boot.log chrony entropy journal lastlog mysql portage sandbox tallylog Xorg.0.log
If you now reboot you’ll see that the text file /var/log/messages
is being used to log system messages, and you can view it easily using commands such as cat
, more
, less
, nano
or whatever, and search through it using grep
etc. Note that the systemd journal service is still running; it is just not logging to a binary file any more and is forwarding system messages to syslog-ng.
Pingback: Bodhi Lives, Jessie Hints, and openSUSE Beta | PHP World
Is it forwarding all events? Does it still need a qr code lib? And a http server for logging?
The answers to these questions please…
hi ,
is there any way to copy the binary files to pc and then convert then to text file
please help me
Just redirect the output of the journalctl command to a text file, like so:
# journalctl > journal.txt
You can use any of the journalctl options to refine your text file. For example, if you wanted to see only the journal messages for the current boot:
# journalctl -b > journal-b.txt
Or if you just wanted to see the kernel messages in the journal:
# journalctl -k > journal-k.txt
And so on. See the journalctl man page for all the options:
http://www.freedesktop.org/software/systemd/man/journalctl.html