# Viewing the connection log

{% note warning %}

Yandex IoT Core is no longer available to new users. 

Current users can create resources until November 1, 2026. Afterwards, the service will go read-only and cease to operate on December 1, 2026. For more information on the timing and procedure, see [Service shutdown](../sunset.md).

{% endnote %}

The log contains information about connecting/disconnecting devices and errors. You can view connection logs for the [registry](#registry) and [devices](#device). Time is specified in [UTC](https://en.wikipedia.org/wiki/Coordinated_Universal_Time).

## View the registry connection log {#registry}

The registry connection log contains information about operations performed with the registry certificate. Operations of devices that belong to this registry are not included in this log.

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the folder to view the registry connection log in.
    1. Navigate to **IoT Core**.
    1. Select the registry with the required device from the list.
    1. Select **Logs** in the left pane of the window.
   
- CLI {#cli}

  When viewing the log, you can set a specific time interval using the `--since` and `--until` flags. If you do not specify a time interval, the log will show info for the last hour.
  
  Using flags:
  
  - `--since`: Time N and later.
  
  - `--until`: Time N and earlier.
  
  If you only specify a single flag, you will see info for one hour before or after time N, depending on the flag.
  
  You can use one of these time formats:
  
  - `HH:MM:SS`, e.g., `15:04:05`.
  
  - [RFC-3339](https://www.ietf.org/rfc/rfc3339.txt), e.g., `2006-01-02T15:04:05Z`, `2h`, or `3h30m ago`.

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).
  
  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. [Get](registry/registry-list.md##registry-list) a list of registries in a folder.

  1. View the registry connection log:
  
        ```bash
        yc iot registry logs my-registry
        ```

        Result:
        ```text
        2019-09-19 18:51:02     connected, cert: "94ea0421199ec70f1f3d359a1c167a81********", address: "77.88.**.***:53171", clientID: "YCCmdLine"
        2019-09-19 18:51:02     some of subscriptions failed: not allowed to subscribe: ["$device/areqjd6un3af********/events"]
        2019-09-19 18:52:30     disconnected: client disconnected
        2019-09-19 18:52:36     connected, cert: "94ea0421199ec70f1f3d359a1c167a81********", address: "77.88.**.***:53198", clientID: "YCCmdLine"
        2019-09-19 18:52:36     some of subscriptions failed: not allowed to subscribe: ["$device/areqjd6un3af********/events"]
        2019-09-19 18:52:54     disconnected: client disconnected
        2019-09-19 18:52:58     connected, cert: "94ea0421199ec70f1f3d359a1c167a81********", address: "77.88.**.***:53209", clientID: "YCCmdLine"
        2019-09-19 18:53:32     disconnected: client disconnected
        ```

{% endlist %}

## View the device connection log {#device}

The device connection log contains information about operations performed with the device certificate.

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the folder to view the device connection log in.
    1. Navigate to **IoT Core**.
    1. Select the registry with the required device from the list.
    1. Select **Devices** in the left pane of the window.
    1. Select the device from the list.
    1. Select **Logs** in the left pane of the window.

- CLI {#cli}

    When viewing the log, you can set a specific time interval using the `--since` and `--until` flags. If you do not specify a time interval, the log will show info for the last hour.
    
    Using flags:
    
    - `--since`: Time N and later.
    
    - `--until`: Time N and earlier.
    
    If you only specify a single flag, you will see info for one hour before or after time N, depending on the flag.
    
    You can use one of these time formats:
    
    - `HH:MM:SS`, e.g., `15:04:05`.
    
    - [RFC-3339](https://www.ietf.org/rfc/rfc3339.txt), e.g., `2006-01-02T15:04:05Z`, `2h`, or `3h30m ago`.

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).
  
    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    1. [Get](device/device-list.md##device-list) a list of devices in a registry.

    1. View the device connection log:

        ```bash
        yc iot devices logs my-device
        ```

        Result:
        ```text
        2019-09-19 18:52:03     connected, cert: "ea7bd563e2352ad87e2aca529cfe3d0c********", address: "77.88.**.***:53189", clientID: "YCCmdLine"
        2019-09-19 18:52:03     disconnected: publish to topic "$device/areqjd6un3af********/events" not allowed
        2019-09-19 18:52:38     connected, cert: "ea7bd563e2352ad87e2aca529cfe3d0c********", address: "77.88.**.***:53201", clientID: "YCCmdLine"
        2019-09-19 18:52:38     disconnected: publish to topic "$device/areqjd6un3af********/events" not allowed
        2019-09-19 18:52:51     connected, cert: "ea7bd563e2352ad87e2aca529cfe3d0c********", address: "77.88.**.***:53206", clientID: "YCCmdLine"
        2019-09-19 18:52:51     disconnected: client disconnected
        2019-09-19 18:53:01     connected, cert: "ea7bd563e2352ad87e2aca529cfe3d0c********", address: "77.88.**.***:53213", clientID: "YCCmdLine"
        2019-09-19 18:53:01     disconnected: client disconnected
        2019-09-19 18:53:03     connected, cert: "ea7bd563e2352ad87e2aca529cfe3d0c********", address: "77.88.**.***:53217", clientID: "YCCmdLine"
        2019-09-19 18:53:03     disconnected: client disconnected
        2019-09-19 18:53:04     connected, cert: "ea7bd563e2352ad87e2aca529cfe3d0c********", address: "77.88.**.***:53220", clientID: "YCCmdLine"
        2019-09-19 18:53:04     disconnected: client disconnected
        ```

{% endlist %}