Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

syslog() Function (Python, SLAX, and XSLT)

Namespaces

Python Syntax

SLAX Syntax

XSLT Syntax

Description

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 integer. The 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.

Parameters

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 message argument 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

auth

Authorization system

4

change

Configuration change log

22

conflict

Configuration conflict log

21

daemon

Various system processes

3

external

Local external applications

18

firewall

Firewall filtering system

19

ftp

FTP processes

11

interact

Commands executed by the UI

23

pfe

Packet Forwarding Engine

20

user

User processes

1

Table 2: Severity Strings
Severity String Description Numeric Value

alert

Conditions that should be corrected immediately

1

crit

Critical conditions

2

debug

Debug messages

7

emerg or panic

Panic conditions

0

err or error

Error conditions

3

info

Informational messages

6

notice

Conditions that should be specially handled

5

warn or warning

Warning messages

4

Usage Examples

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.

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.

Similarly, in Python:

Release Information

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.