Description

By default, a hostname is not included in the header part of the syslog message. This article shows a method where a hostname can be added in the syslog packet, as some syslog utilities require it.

Symptoms

Sample syslog configuration below will not include router's hostname in the header of the syslog message.
 

lab@m40e-re0> show configuration system syslog
host 200.100.1.1 {
     firewall any;
     interactive-commands any;
     facility-override local4;
}

Syslog packet output shows no hostname:
 
Nov 21 02:13:54 mgd[6543]: UI_CMDLINE_READ_LINE: User 'lab', command 'show interfaces terse '

Solution

A workaround is to use log-prefix in the configuration and set it to whatever text you want to add. It can be a hostname or any other prefix required by the design.


lab@Penelope-re0> show configuration system syslog
host 200.100.1.1 {
     firewall any;
     interactive-commands any;
     facility-override local4;
     log-prefix M40e-Sydney ;
}

 
Now syslog packet output contains hostname.
 
Message: Nov 21 01:41:28 M40e-Sydney : mgd[6543]: UI_CMDLINE_READ_LINE: User 'lab', command 'show interfaces terse '

 

Modification History

2022-10-17: Article reviewed for accuracy; no changes required; article valid and relevant.
2019-06-21: Content reviewed for accuracy. Log-prefix link added.

Related Information