Configuring System Logging
The syslog servers run on remote systems that log system messages based on the syslog protocol. You can configure up to eight IPv4 or IPv6 syslog servers.
To support the same configuration of syslog servers on all switches in a fabric, you can use Cisco Fabric Services (CFS) to distribute the syslog server configuration.
Note: When the device first initializes, messages are sent to syslog servers only after the network is initialized.
This section contains payload examples and CLIs to demonstrate how to use the NX-API REST API to configure system logging on Cisco Nexus 3000 and 9000 Series switches and to show how the REST APIs correspond to the CLI commands.
For more information, see the Cisco Nexus 9000 Series NX-OS System Management Configuration Guide, Release 7.x.
Configuring Console logging
Configuring Console logging
POST http://<IP_Address>/api/mo/sys/syslog/console.json
{
"syslogConsole": {
"attributes": {
"adminState": "enabled",
"severity": "critical"
}}}
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html
Configures console logging.
Configuring Module Logging
Configuring Module Logging
POST http://<IP_Address>/api/mo/sys/syslog/inst.json
{
"syslogInst": {
"attributes": {
"modAdminState": "<state>",
"modSeverity": "<severity>"
}}}
Configures the linecard logging instance.
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html
Configuring the Log File
Configuring the Log File
POST http://<IP_Address>/api/mo/sys/syslog/file.json
{
"syslogFile": {
"attributes": {
"adminState": "enabled",
"name": "<logFileName>",
"severity": "<severity>",
"size": "<size>"
}}}
Configures the log file.
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html
Configuring Monitor Logging
Configuring Monitor Logging
POST http://<IP_Address>/api/mo/sys/syslog/monitor.json
{
"syslogTermMonitor": {
"attributes": {
"adminState": "<state>",
"severity": "<severity>"
}}}
Configures monitor logging.
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html
Configuring the Logging Timestamp
Configuring the Logging Timestamp
POST http://<IP_Address>/api/mo/sys/syslog/timestamp.json
{
"syslogTimeStamp": {
"attributes": {
"format": "<granularity>"
}}}
Configures logging timestamp granularity.
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html
Configuring Interface Logging
Configuring Interface Logging
POST http://<IP_Address>/api/mo/sys/syslog/source.json
{
"syslogSourceInterface": {
"attributes": {
"adminState": "<state>",
"ifName": "<interface><slot>/<port>"
}}}
Enables and configures logging on an interface.
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html
Configuring Logging Level
Enables and configures logging level on a system facility.
POST http://<IP_Address>/api/mo/sys/syslog/level-<facility-name>.json
Configuring the logging level for AAA at "Alert" level.
{
"aaaUserEp": {
"children": [
{
"aaaAuthRealm": {
"attributes": {
"loggingLevel": "Alert"
}}}]}}
Enables and configures logging level on a system facility.
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html
Configuring Remote Logging Server
Configuring Remote Logging Server
POST http://<IP_Address>/api/mo/sys/syslog.json
{
"syslogSyslog": {
"children": [
{
"syslogRemoteDest": {
"attributes": {
"forwardingFacility": "<facility>",
"host": "<hostname>",
"severity": "<severity>",
"vrfName": "<vrfName>"
}}}]}}
Configures remote logging on a server.
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html
Clearing a Logfile
Clearing a Logfile
POST http://<IP_Address>/api/mo/sys/action.json
{
"actionLSubj": {
"attributes": {
"dn": "sys/action/lsubj-[sys/syslog]"
}
"children" : [{
"syslogFileClearLogfileLTask" : {
"attributes" : {
"adminSt" : "start",
"dn" : "sys/action/lsubj-[sys/syslog]/syslogFileClearLogfileLTask",
"freq": "one-shot"
}}}]}}
Clears the logfile.
See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/
For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html