Skip to content

How to extend syslog max length per line in Ubuntu 20.04


Default max message length

Syslog is an essential system logging utility present in most Linux distributions, including Ubuntu 20.04. It collects and records messages from various system components, including the kernel, applications, and services. However, by default, in Ubuntu 20.04, max message length per line in /var/log/syslog is 8Kb, and some other Distribution like CentOS may be 1kb or 2kb.

Change the default max length

Edit /etc/rsyslog.conf to set $MaxMessageSize in first line.

# /etc/rsyslog.conf configuration file for rsyslog
# For more information install rsyslog-doc and see
# /usr/share/doc/rsyslog-doc/html/configuration/index.html
# Default logging rules can be found in /etc/rsyslog.d/50-default.conf

$MaxMessageSize 12k

Then restart rsyslog service.

sudo systemctl restart rsyslog.service

Verifying the New Maximum Length per Line

To verify that the new maximum length per line is in effect, we can use the logger command to generate a long message and check if syslog records it in a single line. Follow the steps below to do so:

  1. Open the terminal and run the command logger -s -t TEST "This is a long test message with more than 4096 characters to verify the new maximum length per line.".
  2. Open the syslog file located at /var/log/syslog using your preferred text editor.
  3. Find the line that contains the message generated in step 1 and check if it is recorded in a single line.

If the message is recorded in a single line, the new maximum length per line is in effect. If not, review the steps above and ensure that you have made the appropriate changes to the syslog configuration file.


Leave your message