Advertisements

Ubuntu real-time syslog logging to unused console TTY

Without going into a full run down on Ubuntu TTYs and how they work, there’s a very simple way to have Ubuntu log events in real-time to an unused TTY that you can access with a quick keystroke. This gives you the ability to see log events in real-time for easier troubleshooting.

This probably isn’t news to some. as it’s already written in the configuration file and just commented out, but I always seem to forget how to enable it, and I’m sure some other people would appreciate this.

First, what we’ll do is enable syslog to log events to an unused TTY. Edit /etc/rsyslog.d/50-default.conf and look for the following section:

#daemon,mail.*;
#       news.=crit;news.=err;news.=notice;
#       *.=debug;*.=info;
#       *.=notice;*.=warn       /dev/tty8

You can use TTY8, but I prefer TTY12 for reasons that involve X. Change /dev/tty8 to /dev/tty12, and remove the # comment marks from all 4 lines to enable it. Save.

Restart the rsyslogd service:

/etc/init.d/rsyslogd restart

You could also use the upstart restart method:

restart rsyslog

Now you’ve got this set up, how do you view it? Press CTRL-ALT-F12 on your keyboard to go to TTY12 and view your real-time log. To get back to your X (GUI) session, CTRL-ALT-F7 or CTRL-ALT-F8 (X usually runs on TTY7, but can be running on TTY8 sometimes.)

Update 4/26/17:

Newer versions of syslogd may require a backslash or pipe symbol like in the two following example configs to work properly:

daemon,mail.*;
       news.=crit;news.=err;news.=notice;
       *.=debug;*.=info;
       *.=notice;*.=warn       |/dev/tty12
daemon,mail.*;\
       news.=crit;news.=err;news.=notice;\
       *.=debug;*.=info;\
       *.=notice;*.=warn       /dev/tty12

Any thoughts or comments on the above? Please feel free to share them in the comments section below.

Advertisements

  1. #1 by Dàrent on June 29, 2011 - 1:16 pm

    I didn’t even knew there is more tty’s after the gui in tty7 or 8 xD
    Really usefull, thanks :)

    • #2 by Mike on June 30, 2011 - 9:10 pm

      Yes — you can actually go up to TTY20. To get access to the TTYs after 12 (F12), there’s a key modifier… I think it’s shift+alt, but I don’t recall exactly.

  2. #3 by pietrek on April 29, 2012 - 8:49 am

    Nice tip, thanks! I noticed one thing missing tho’. You have to pipe the output to the console of your choice to make it work (this can be related some recent changes in Ubuntu, I didn’t know about).

    End result should look like this:

    daemon,mail.*;
    news.=crit;news.=err;news.=notice;
    *.=debug;*.=info;
    *.=notice;*.=warn |/dev/tty12 ;<= notice the | pipe sign.

    • #4 by Mike Beach on May 2, 2012 - 9:14 pm

      You may be right. Thanks for the update!