Directing Messages to a Log File
To direct system log messages to a file in the /var/log directory of the local Routing Engine, include the file statement at the [edit system syslog] hierarchy level:
[edit system syslog]
file filename {
facility severity ;
explicit-priority;
match "regular-expression";
structured-data {
brief;
}
archive {
files number ;
size size;
(world-readable | no-world-readable);
}
}For the list of facilities and severity levels, see Specifying the Facility and Severity of Messages to Include in the Log.
To prevent log files from growing too large, the Junos system logging utility by default writes messages to a sequence of files of a defined size. By including the archive statement, you can configure the number of files, their maximum size, and who can read them, for either all log files or a certain log file. For more information, see Configuring the Size and Number of Log Files.
For information about the following statements, see the indicated sections:
- explicit-priority—See Including Priority Information in System Log Messages.
- match—See Using Regular Expressions to Refine the Set of Logged Messages.
- structured-data—See Logging Messages in Structured-Data Format.
Logging Messages in Structured-Data Format
In Junos 8.3 and later, you can log messages to a file in structured-data format instead of the standard Junos format. Structured-data format provides more information without adding significant length, and makes it easier for automated applications to extract information from a message.
The structured-data format complies with Internet draft draft-ietf-syslog-protocol-21.txt, The draft establishes a standard message format regardless of the source or transport protocol for logged messages.
To output messages to a file in structured-data format, include the structured-data statement at the [edit system syslog file filename] hierarchy level:
[edit system syslog file filename]
facility severity;
structured-data {
brief;
}The optional brief statement suppresses the English-language text that appears by default at the end of a message to describe the error or event. For information about the fields in a structured-data–format message, see Displaying a Log File from a Single-Chassis System.
The structured format is used for all messages logged to the file that are generated by a Junos process or software library.
![]() | Note: If you include either or both of the explicit-priority and time-format statements along with the structured-data statement, they are ignored. These statements apply to the standard Junos system log format, not to structured-data format. |
Hide Navigation Pane
Show Navigation Pane
Download
SHA1
