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.

https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-installation-and-configuration-guides-list.html/

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

Using the Hostname as the Origin Id of Logging Messages

Using the Hostname as the Origin Id of Logging Messages
POST http://<mgmt0_IP>/api/mo/sys/syslog.json
{
  "syslogSyslog": {
    "children": [
      {
        "syslogOriginid": {
          "attributes": {
            "idtype": "hostname"
          }
        }
      }
    ]
  }
}
{
    imdata:[]
}
<System>
  <syslog-items>
    <originid-items>
      <idtype>hostname</idtype>
    </originid-items>
  </syslog-items>
</System>

Note: This example was added in Release 9.2(3).


CLI Commands

The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.

logging origin-id hostname

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference:
http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

For detailed information about classes and attributes in the payload, see the NX-API DME Model Reference:
https://developer.cisco.com/media/dme/index.html

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

Disabling the Hostname as the Origin Id of Logging Messages

Disabling the Hostname as the Origin Id of Logging Messages
POST http://<mgmt0_IP>/api/mo/sys/syslog.json
{
  "syslogSyslog": {
    "children": [
      {
        "syslogOriginid": {
          "attributes": {
            "status": "deleted"
          }
        }
      }
    ]
  }
}
{
    imdata:[]
}
<System>
  <syslog-items>
    <originid-items xc:operation="delete">
    </originid-items>
  </syslog-items>
</System>

Note: This example was added in Release 9.2(3).


CLI Commands

The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.

no logging origin-id hostname

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference:
http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

For detailed information about classes and attributes in the payload, see the NX-API DME Model Reference:
https://developer.cisco.com/media/dme/index.html

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

Using the IP as the Origin Id of Logging Messages

Using the IP as the Origin Id of Logging Messages
POST http://<mgmt0_IP>/api/mo/sys/syslog.json
{
  "syslogSyslog": {
    "children": [
      {
        "syslogOriginid": {
          "attributes": {
            "idtype": "ip",
            "idvalue": "1.2.3.4"
          }
        }
      }
    ]
  }
}
{
    imdata:[]
}
<System>
  <syslog-items>
    <originid-items>
      <idtype>ip</idtype>
      <idvalue>1.2.3.4</idvalue>
    </originid-items>
  </syslog-items>
</System>

Note: This example was added in Release 9.2(3).


CLI Commands

The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.

logging origin-id ip 1.2.3.4

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference:
http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

For detailed information about classes and attributes in the payload, see the NX-API DME Model Reference:
https://developer.cisco.com/media/dme/index.html

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

Disabling the IP as the Origin Id of Logging Messages

Disabling the IP as the Origin Id of Logging Messages
POST http://<mgmt0_IP>/api/mo/sys/syslog.json
{
  "syslogSyslog": {
    "children": [
      {
        "syslogOriginid": {
          "attributes": {
            "status": "deleted"
          }
        }
      }
    ]
  }
}
{
    imdata:[]
}
<System>
  <syslog-items>
    <originid-items xc:operation="delete">
    </originid-items>
  </syslog-items>
</System>

Note: This example was added in Release 9.2(3).


CLI Commands

The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.

no logging origin-id ip 1.2.3.4

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference:
http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

For detailed information about classes and attributes in the payload, see the NX-API DME Model Reference:
https://developer.cisco.com/media/dme/index.html

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

Appending a String to the Front of Syslog Messages

Appending a String to the Front of Syslog Messages
POST http://<mgmt0_IP>/api/mo/sys/syslog.json
{
  "syslogSyslog": {
    "children": [
      {
        "syslogOriginid": {
          "attributes": {
            "idtype": "string",
            "idvalue": "SampleString_123"
          }
        }
      }
    ]
  }
}
{
    imdata:[]
}
<System>
  <syslog-items>
    <originid-items>
      <idtype>string</idtype>
      <idvalue>SampleString_123</idvalue>
    </originid-items>
  </syslog-items>
</System>

Note: This example was added in Release 9.2(3).


CLI Commands

The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.

logging origin-id string SampleString_123

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference:
http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

For detailed information about classes and attributes in the payload, see the NX-API DME Model Reference:
https://developer.cisco.com/media/dme/index.html

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

Removing a String from the Front of Syslog Messages

Removing a String from the Front of Syslog Messages
POST http://<mgmt0_IP>/api/mo/sys/syslog.json
{
  "syslogSyslog": {
    "children": [
      {
        "syslogOriginid": {
          "attributes": {
            "status": "deleted"
          }
        }
      }
    ]
  }
}
{
    imdata:[]
}
<System>
  <syslog-items>
    <originid-items xc:operation="delete">
    </originid-items>
  </syslog-items>
</System>

Note: This example was added in Release 9.2(3).


CLI Commands

The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.

no logging origin-id string SampleString_123

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference:
http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

For detailed information about classes and attributes in the payload, see the NX-API DME Model Reference:
https://developer.cisco.com/media/dme/index.html

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