[Contents] [Prev] [Next] [Index] [Report an Error]

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 Specifying Log File Size, Number, and Archiving Properties.

For information about the following statements, see the indicated sections:

Logging Messages in Structured-Data Format

In JUNOS Release 8.3 and later, you can log messages to a file in structured-dataformat 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 syslog Protocol, which at the time of this writing is accessible at http://www.ietf.org/internet-drafts/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 the JUNOS System Log Messages Reference.

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.


[Contents] [Prev] [Next] [Index] [Report an Error]