# iosxr_logging – Configuration management of system logging services on network devices

New in version 2.4.

- Synopsis
- Requirements
- Parameters
- Notes
- Examples
- Return Values
- Status

## Synopsis

- This module provides declarative management configuration of system logging (syslog) on Cisco IOS XR devices.

## Requirements

The below requirements are needed on the host that executes this module.

- ncclient >= 0.5.3 when using netconf
- lxml >= 4.1.1 when using netconf

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
aggregate - |  | List of syslog logging configuration definitions.

dest
-

Choices:
- host
- console
- monitor
- buffered
- file

Destination for system logging (syslog) messages.

facility - | Default: "local7" | To configure the type of syslog facility in which system logging (syslog) messages are sent to syslog servers Optional config for `dest` = `host`
hostnameprefix - added in 2.5 |  | To append a hostname prefix to system logging (syslog) messages logged to syslog servers. Optional config for `dest` = `host`
level - | Default: "debugging" | Specifies the severity level for the logging. aliases: severity
name - |  | When `dest` = file name indicates file-name When `dest` = host name indicates the host-name or ip-address of syslog server.

provider
dictionary

Deprecated
Starting with Ansible 2.5 we recommend using `connection: network_cli`.
For more information please see the Network Guide.

A dict object containing connection details.

| host string / required |  | Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
| password string |  | Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable `ANSIBLE_NET_PASSWORD` will be used instead.
| port integer | Default: 22 | Specifies the port to use when building the connection to the remote device.
| ssh_keyfile path |  | Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable `ANSIBLE_NET_SSH_KEYFILE` will be used instead.
| timeout integer | Default: 10 | Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.
| username string |  | Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable `ANSIBLE_NET_USERNAME` will be used instead.
size - |  | Size of buffer when `dest` = `buffered`. The acceptable value is in the range 307200 to 125000000 bytes. Default 307200 Size of file when `dest` = `file`. The acceptable value is in the range 1 to 2097152KB. Default 2 GB

state
-

Choices:
- present ←
- absent

Existential state of the logging configuration on the node.

vrf - added in 2.5 | Default: "default" | vrf name when syslog server is configured, `dest` = `host`

## Notes

Note

- This module works with connection `network_cli` and `netconf`. See the IOS-XR Platform Options.
- Tested against IOS XRv 6.1.3
- For more information on using Ansible to manage network devices see the Ansible Network Guide
- For more information on using Ansible to manage Cisco devices see the Cisco integration page.

## Examples

    - name: configure logging for syslog server host
      iosxr_logging:
        dest: host
        name: 10.10.10.1
        level: critical
        state: present

    - name: add hostnameprefix configuration
      iosxr_logging:
        hostnameprefix: host1
        state: absent

    - name: add facility configuration
      iosxr_logging:
        facility: local1
        state: present

    - name: configure console logging level
      iosxr_logging:
        dest: console
        level: debugging
        state: present

    - name: configure monitor logging level
      iosxr_logging:
        dest: monitor
        level: errors
        state: present

    - name: configure syslog to a file
      iosxr_logging:
        dest: file
        name: file_name
        size: 2048
        level: errors
        state: present

    - name: configure buffered logging with size
      iosxr_logging:
        dest: buffered
        size: 5100000

    - name: Configure logging using aggregate
      iosxr_logging:
        aggregate:
          - { dest: console, level: warning }
          - { dest: buffered, size: 4800000 }
          - { dest: file, name: file3, size: 2048}
          - { dest: host, name: host3, level: critical}

    - name: Delete logging using aggregate
      iosxr_logging:
        aggregate:
          - { dest: console, level: warning }
          - { dest: buffered, size: 4800000 }
          - { dest: file, name: file3, size: 2048}
          - { dest: host, name: host3, level: critical}
        state: absent

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Returned | Description
--- | --- | ---

commands
list

always (empty list when no commands to send)

The list of configuration mode commands to send to the device
Sample:
['logging 10.10.10.1 vrf default severity debugging', 'logging facility local7', 'logging hostnameprefix host1', 'logging console critical', 'logging buffered 2097153', 'logging buffered warnings', 'logging monitor errors', 'logging file log_file maxfilesize 1024 severity info']

xml
list
added in 2.5

always (empty list when no xml rpc to send)

NetConf rpc xml sent to device with transport `netconf`
Sample:
['<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> <syslog xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-syslog-cfg"> <files> <file xc:operation="delete"> <file-name>file1</file-name> <file-log-attributes> <max-file-size>2097152</max-file-size> <severity>2</severity> </file-log-attributes> </file> </files> </syslog> </config>']

## Status

- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Network Team. [network]

### Red Hat Support

More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.

### Authors

- Trishna Guha (@trishnaguha)
- Kedar Kekan (@kedarX)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.