syslog() Function (Python, SLAX, and XSLT)
Function introduced in Junos OS Release 7.6
Support for the slax namespace http://xml.libslax.org/slax added in Junos OS Release 12.2.
Support for Python added in Junos OS Release 16.1R1 on QFX Series switches and ACX Series, MX Series, PTX Series, and T Series routers.
Support for Python added in Junos OS Release 17.1R1 on ACX500, ACX1000, ACX1100, ACX2000, ACX2100, ACX2200, and ACX4000 routers, and EX Series switches.
Support for Python added in Junos OS Release 17.3R1 on SRX1500, SRX4100, SRX4200, SRX5400, SRX5600, and SRX5800 devices and vSRX instances.
Support for Python added in Junos OS Release 18.3R1 on ACX5048 and ACX5096 routers.
Log messages with the specified priority to the system log file.
The priority can be expressed as a
facility.severity string or as a calculated
message argument is a string that is written to the system log file. Optionally,
additional strings can be included in the argument list. The
message argument is concatenated
with any additional arguments, and the concatenated string is written
to the system log file. The syslog file is specified at the [edit
system syslog] hierarchy level of the configuration.
The prefix associated with the namespace URI should be defined in the prefix-to-namespace mapping in the style sheet.
message—String that is output to the system log file.
message2—(Optional) Any additional number of strings passed as arguments to the function. These are concatenated with the
messageargument and output to the system log file.
priority—Priority given to the syslog message.
The priority can be specified as a
facility.severity string, or it can expressed
as an integer calculated from the corresponding numeric values of
the facility and severity strings. In Python scripts, the priority
integer value must be passed in as a string.
Table 1 and Table 2 show the available
facility and severity strings and their corresponding numeric values.
The integer value of the
priority parameter is calculated by multiplying the numeric
value of the facility string by 8 and adding the numeric value of
the severity string. For example, if the
facility.severity string pair is
"pfe.alert", the priority value is 161 ((20 x 8)+1).
Table 1: Facility Strings
|Facility String||Description||Numeric Value|
Configuration change log
Configuration conflict log
Various system processes
Local external applications
Firewall filtering system
Commands executed by the UI
Table 2: Severity Strings
|Severity String||Description||Numeric Value|
Conditions that should be corrected immediately
emerg or panic
err or error
Conditions that should be specially handled
warn or warning
The following three SLAX examples log pfe messages with an alert priority. The string "
mymessage" is output to the system log file. All three
examples are equivalent.
expr jcs:syslog("pfe.alert", "mymessage");
expr jcs:syslog(161, "mymessage");
var $message = "mymessage";
expr jcs:syslog("pfe.alert", $message);
The following example logs pfe messages with an alert priority similar to the previous example. In this example,
however, there are additional string arguments. For this case, the
concatenated string "
mymessage mymessage2" is output to the system log file.
expr jcs:syslog("pfe.alert", "mymessage ", "mymessage2");
Similarly, in Python:
jcs.syslog("pfe.alert", "message") jcs.syslog("161", "message")