Dynamic Logger

Prerequisites

Before using dynamic logging, confirm that the following are on your switch:

  • The libmtxlogmgr*.so library is installed /opt/mtx/lib/. The libmtxlogmgr*.so library is part of the mtx_infra RPM.

  • The mtx.conf file that is located in /etc/ contains:

    [mtxlogger]
    config=/opt/mtx/conf/mtxlogger.cfg
  • The mtxlogger.cfg file is in /opt/mtx/conf/.

Reference

The configuration file has the following structure:

<config name="nxos-device-mgmt">
  <container name="mgmtConf">
    <container name="logging">
      <leaf name="enabled" type="boolean" default="false"></leaf>
      <leaf name="allActive" type="boolean" default="false"></leaf>
      <container name="format">
        <leaf name="content" type="string" default="$DATETIME$ $COMPONENTID$ $TYPE$: $MSG$"></leaf>
	    <container name="componentID">
            <leaf name="enabled" type="boolean" default="true"></leaf>         
	    </container>	
	    <container name="dateTime">
            <leaf name="enabled" type="boolean" default="true"></leaf>         
            <leaf name="format" type="string" default="%y%m%d.%H%M%S"></leaf>
	    </container>	
	    <container name="fcn">
            <leaf name="enabled" type="boolean" default="true"></leaf>         
            <leaf name="format" type="string" default="$CLASS$::$FCNNAME$($ARGS$)@$LINE$"></leaf>
	    </container>	
      </container>
      <container name="dest">
        <container name="console">
          <leaf name="enabled" type="boolean" default="false"></leaf>         
        </container>
        <container name="file">
          <leaf name="enabled" type="boolean" default="false"></leaf>  
          <leaf name="name" type="string" default="mtx-internal.log"></leaf>
          <leaf name="location" type="string" default="./mtxlogs"></leaf>
	   <leaf name="mbytes-rollover" type="uint32" default="10"></leaf>
	   <leaf name="hours-rollover" type="uint32" default="24"></leaf>
	   <leaf name="startup-rollover" type="boolean" default="false"></leaf>
          <leaf name="max-rollover-files" type="uint32" default="10"></leaf>
        </container>
      </container>
      <list name="logitems" key="id">
        <listitem>
        	<leaf name="id" type="string"></leaf>
		 <leaf name="active" type="boolean" default="true"></leaf>
        </listitem>
      </list>
    </container>
  </container>
</config>   

The <list> tag defines the log filters by <componentID> .

The following table describes some of the containers and their leaves.

Table 1. Container and Leaf Descriptions

Container

Container Description

Contained Containers

Contained Leaf and Description

logging

Contains all logging data types

format

dest

file

Note

 

Also contains list tag "logitems"

enabled: Boolean that determines whether logging is on or off. Default off.

allActive: Boolean that activates all defined logging items for logging. Default off

format

Contains the log message format information

componentID

dateTime

type

fcn

content: String listing data types included in log messages. Includes:

  • $DATETIME$: Include date or time in log message

  • $COMPONENTID$: Include component name in log message.

  • $TYPE$: Includes message type ("", INFO, WARNING, ERROR)

  • $SRCFILE$: Includes name of source file.

  • $SRCLINE$: Include line number of source file

  • $FCNINFO$ Include class::function name from the source file.

  • $MSG$: Include actual log message text.

componentID

Name of logged component.

NA

enabled: Boolean that determines if the log message includes the component ID. Default to "true." Value of "false" returns a "" string in log message.

dateTime

Date or time of log message

NA

enabled: Boolean whether to include date or time information in log message. Default is enabled.

format: String of values to include in log message. Format of %y%m%d.%H%M%S.

dest

Holds destination logger's configuration settings.

console: Destination console. Only one allowed.

file: destination file. Multiple allowed.

NA

console

Destination console

NA

enabled: Boolean that determines whether the console is enabled for logging. Default of "false."

file

Determines the settings of the destination file.

NA

enabled: Boolean that determines whether the destination is enabled. Default is "false."

name: String of the destination log file. Default of "mtx-internal.log"

location: String of destination file path. Default at "./mtxlogs."

mbytes-rollover: uint32 that determines the length of the log file before the system overwrites the oldest data. Default is 10 Mbytes.

hours-rollover: uint32 that determines the length of the log file in terms of hours. Default is 24 hours.

startup-rollover: Boolean that determines if the log file is rolled over upon agent start or restart. Default value of "false."

max-rollover-files: uint32 that determines the maximum number of rollover files; deletes the oldest file when the max-rollover-files value exceeded. Default value of 10.

Example

The following is the configuration file with the default installed configuration.
<config name="nxos-device-mgmt">
  <container name="mgmtConf">
    <container name="logging">
      <leaf name="enabled" type="boolean" default="false">true</leaf>
      <leaf name="allActive" type="boolean" default="false">false</leaf>
      <container name="format">
        <leaf name="content" type="string" default="$DATETIME$ $COMPONENTID$ $TYPE$: $MSG$">$DATETIME$ $COMPONENTID$ $TYPE$ $SRCFILE$ @ $SRCLINE$ $FCNINFO$:$MSG$</leaf>
	    <container name="componentID">
            <leaf name="enabled" type="boolean" default="true"></leaf>         
	    </container>	
	    <container name="dateTime">
            <leaf name="enabled" type="boolean" default="true"></leaf>         
            <leaf name="format" type="string" default="%y%m%d.%H%M%S"></leaf>
	    </container>	
	    <container name="fcn">
            <leaf name="enabled" type="boolean" default="true"></leaf>         
            <leaf name="format" type="string" default="$CLASS$::$FCNNAME$($ARGS$)@$LINE$"></leaf>
	    </container>	
      </container>
      <container name="dest">
        <container name="console">
          <leaf name="enabled" type="boolean" default="false">true</leaf>         
        </container>
        <container name="file">
          <leaf name="enabled" type="boolean" default="false">true</leaf>  
          <leaf name="name" type="string" default="mtx-internal.log"></leaf>
          <leaf name="location" type="string" default="./mtxlogs">/volatile</leaf>
	   <leaf name="mbytes-rollover" type="uint32" default="10">50</leaf>
	   <leaf name="hours-rollover" type="uint32" default="24">24</leaf>
	   <leaf name="startup-rollover" type="boolean" default="false">true</leaf>
          <leaf name="max-rollover-files" type="uint32" default="10">10</leaf>
        </container>
      </container>
      <list name="logitems" key="id">
        <listitem>
        	<leaf name="id" type="string">*</leaf>
		 <leaf name="active" type="boolean" default="false">false</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">SYSTEM</leaf>
		 <leaf name="active" type="boolean" default="true">true</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">LIBUTILS</leaf>
		 <leaf name="active" type="boolean" default="true">true</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">MTX-API</leaf>
		 <leaf name="active" type="boolean" default="true">true</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">Model-*</leaf>
		 <leaf name="active" type="boolean" default="true">true</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">Model-Cisco-NX-OS-device</leaf>
		 <leaf name="active" type="boolean" default="true">false</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">Model-openconfig-bgp</leaf>
		 <leaf name="active" type="boolean" default="true">false</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">INST-MTX-API</leaf>
		 <leaf name="active" type="boolean" default="true">false</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">INST-ADAPTER-NC</leaf>
		 <leaf name="active" type="boolean" default="true">false</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">INST-ADAPTER-RC</leaf>
		 <leaf name="active" type="boolean" default="true">false</leaf>
        </listitem>
        <listitem>
        	<leaf name="id" type="string">INST-ADAPTER-GRPC</leaf>
		 <leaf name="active" type="boolean" default="true">false</leaf>
        </listitem>
      </list>
    </container>
  </container>
</config>