ON THIS PAGE
Example: Trace NETCONF and Junos XML Protocol Session Operations
This example configures tracing operations for NETCONF and Junos XML protocol sessions.
Requirements
A device running Junos OS or a device running Junos OS Evolved.
Overview
This example configures basic tracing operations for NETCONF and Junos XML protocol sessions.
When you configure tracing operations at the [edit system services netconf
traceoptions] hierarchy, the device enables tracing operations for both
NETCONF and Junos XML protocol sessions. The system adds the
[NETCONF] or [JUNOScript] tag to the log file
entries to distinguish the session type.
In this example, you configure the trace file netconf-ops.log.
You configure a maximum number of 20 trace files and a maximum size of 3 MB for each
file. The flag all statement configures tracing for all incoming
and outgoing NETCONF and Junos XML protocol data. The
world-readable option enables unrestricted access to the trace
files.
Configuration
CLI Quick Configuration
To quickly configure this example, copy the following
commands, paste them in a text file, remove any line breaks, change
any details necessary to match your network configuration, and then
copy and paste the commands into the CLI at the [edit] hierarchy
level.
set system services netconf ssh set system services netconf traceoptions file netconf-ops.log set system services netconf traceoptions file size 3m set system services netconf traceoptions file files 20 set system services netconf traceoptions file world-readable set system services netconf traceoptions flag all
Configure NETCONF and Junos XML Protocol Tracing Operations
Step-by-Step Procedure
To configure NETCONF and Junos XML protocol tracing operations:
For NETCONF sessions, enable NETCONF over SSH.
[edit] user@R1# set system services netconf ssh
Configure the traceoptions flag to specify which session data to capture.
You can specify incoming, outgoing, all, or debug data. This example configures tracing for all session data.
[edit] user@R1# set system services netconf traceoptions flag all
(Optional) Configure the filename of the trace file.
The following statement configures the trace file /var/log/netconf-ops.log. If you do not specify a filename, the system logs NETCONF and Junos XML protocol session data in /var/log/netconf.
[edit] user@R1# set system services netconf traceoptions file netconf-ops.log
(Optional) Configure the maximum number of trace files and the maximum size of each file.
The following statements configure a maximum of 20 trace files with a maximum size of 3 MB per file.
[edit] user@R1# set system services netconf traceoptions file files 20 user@R1# set system services netconf traceoptions file size 3m
(Optional) Restrict the trace output to include only those lines that match a particular regular expression.
The following configuration, which is not used in this example, matches on and logs only session data that contains “error-message”.
[edit] user@R1# set system services netconf traceoptions file match error-message
(Optional) Configure on-demand tracing to control tracing operations from the NETCONF or Junos XML protocol session.
The following configuration, which is not used in this example, enables on-demand tracing.
[edit] user@R1# set system services netconf traceoptions on-demand
(Optional) Configure the permissions on the trace file by specifying whether the file is
world-readableorno-world-readable.This example enables unrestricted access to the trace file.
[edit] user@R1# set system services netconf traceoptions file world-readable
Commit the configuration.
[edit] user@R1# commit
Results
[edit]
system {
services {
netconf {
ssh;
traceoptions {
file netconf-ops.log size 3m files 20 world-readable;
flag all;
}
}
}
}
Verification
Verify NETCONF and Junos XML Protocol Tracing Operation
Purpose
Verify that the device logs NETCONF and Junos XML protocol operations to the configured trace file. This example logs both incoming and outgoing NETCONF and Junos XML protocol data. In the sample NETCONF session, which is not detailed here, the user modifies the candidate configuration to include the bgp-troubleshoot.slax op script and then commits the configuration.
Action
Display the configured trace file by issuing the show log filename operational mode command.
user@R1 show log netconf-ops.log Apr 3 13:09:04 [NETCONF] Started tracing session: 3694 Apr 3 13:09:29 [NETCONF] - [3694] Incoming: <rpc> Apr 3 13:09:29 [NETCONF] - [3694] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/24.4R1/junos"> Apr 3 13:09:39 [NETCONF] - [3694] Incoming: <edit-config> Apr 3 13:09:43 [NETCONF] - [3694] Incoming: <target> Apr 3 13:09:47 [NETCONF] - [3694] Incoming: <candidate/> Apr 3 13:09:53 [NETCONF] - [3694] Incoming: </target> Apr 3 13:10:07 [NETCONF] - [3694] Incoming: <default-operation>merge</default-operation> Apr 3 13:10:10 [NETCONF] - [3694] Incoming: <config> Apr 3 13:10:13 [NETCONF] - [3694] Incoming: <configuration> Apr 3 13:10:16 [NETCONF] - [3694] Incoming: <system> Apr 3 13:10:19 [NETCONF] - [3694] Incoming: <scripts> Apr 3 13:10:23 [NETCONF] - [3694] Incoming: <op> Apr 3 13:10:26 [NETCONF] - [3694] Incoming: <file> Apr 3 13:10:44 [NETCONF] - [3694] Incoming: <name>bgp-troubleshoot.slax</name> Apr 3 13:10:46 [NETCONF] - [3694] Incoming: </file> Apr 3 13:10:48 [NETCONF] - [3694] Incoming: </op> Apr 3 13:10:52 [NETCONF] - [3694] Incoming: </scripts> Apr 3 13:10:56 [NETCONF] - [3694] Incoming: </system> Apr 3 13:11:00 [NETCONF] - [3694] Incoming: </configuration> Apr 3 13:11:00 [NETCONF] - [3694] Outgoing: <ok/> Apr 3 13:11:12 [NETCONF] - [3694] Incoming: </config> Apr 3 13:11:18 [NETCONF] - [3694] Incoming: </edit-config> Apr 3 13:11:26 [NETCONF] - [3694] Incoming: </rpc> Apr 3 13:11:26 [NETCONF] - [3694] Outgoing: </rpc-reply> Apr 3 13:11:26 [NETCONF] - [3694] Outgoing: ]]>]]> Apr 3 13:11:31 [NETCONF] - [3694] Incoming: ]]>]]> Apr 3 13:14:20 [NETCONF] - [3694] Incoming: <rpc> Apr 3 13:14:20 [NETCONF] - [3694] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/24.4R1/junos"> Apr 3 13:14:26 [NETCONF] - [3694] Incoming: <commit/> Apr 3 13:14:35 [NETCONF] - [3694] Outgoing: <ok/> Apr 3 13:14:35 [NETCONF] - [3694] Incoming: </rpc> Apr 3 13:14:35 [NETCONF] - [3694] Outgoing: </rpc-reply> Apr 3 13:14:35 [NETCONF] - [3694] Outgoing: ]]>]]> Apr 3 13:14:40 [NETCONF] - [3694] Incoming: ]]>]]> Apr 3 13:30:48 [NETCONF] - [3694] Outgoing: <!-- session end at 2025-04-03 13:30:48 PDT -->
Meaning
This example configures the flag all statement, so the trace file logs all
incoming and outgoing data for any NETCONF and Junos XML protocol sessions.
Each operation includes the date and timestamp. The log file indicates the
session type, either NETCONF or Junos XML protocol, by including the
[NETCONF] or [JUNOScript] tag,
respectively. The device distinguishes multiple NETCONF and Junos XML
protocol sessions by using a unique session number. In this example, only
one NETCONF session, using session identifier 3694, is active.