---
title: "How to use REST Service to pause and resume database logging"
description: "Pausing and resuming database logging in Geneos is done using REST Service commands after enabling the REST Service on the gateway. Successful commands update the gateway log and UI icons, with connection status reflecting actual database activity."
url: "https://docs.itrsgroup.com/docs/faq/geneos/4419528586257-geneos-how-to-use-rest-service-to-pause-and-resume-database-logging/index.html"
---
## Prerequisites

The REST Service must be enabled on the gateway by doing the following steps:

1. In the GSE, click **Commands**.
2. Select the **Advanced** tab.
3. In **Rest service**, check the box next to **Enabled**.
4. Save change in the GSE.

![REST service enabled](https://docscdn.itrsgroup.com/faq/images/geneos/enable-rest-service.png)

### Solution

To pause database logging using REST API, run the following command:

```
curl -u username:password -X POST -s --data '{ "command" : "/DATABASELOGGING:connection:pause", "target":" /geneos/gateway/directory[(rparam(\"DBConnectionPaused\")=\"false\")]"}' http://gatewayHost:gatewayPort/rest/runCommand
```

If the REST API command is successful, you will see the following response on the terminal.

```
{ "status":"finished" }
```

In addition, the gateway's database logging icon will appear red and crossed out, indicating the gateway is not connected to the database.

![Disconnected Gateway](https://docscdn.itrsgroup.com/faq/images/geneos/disconnected-gateway-icon.png)

If you are using the [Gateway-databaseLogging plug-in](https://docs.itrsgroup.com/docs/geneos/current/processing/data-access-and-publishing/geneos_dblogging_tr/index.html), you will notice the Summary dataview shows connectionPaused set to `true`.

![Pause connection of Database Logging](https://docscdn.itrsgroup.com/faq/images/geneos/connectionpaused-view.png)

The gateway log will show the command has been executed and the database connection has been paused:

```
2022-03-23 15:43:50.903-0400 INFO: CommandManager Executing command [/DATABASELOGGING:connection:pause] with id [116] for request id [26]
2022-03-23 15:43:50.904-0400 INFO: CommandManager Executing command '/DATABASELOGGING:connection:pause' on DataItem '/geneos/gateway[(@name="testing_gateway")]/directory', issued by user 'username' on '192.168.x.xx' using REST service
2022-03-23 15:43:50.904-0400 INFO: CommandManager Received 0 arguments for command
2022-03-23 15:43:50.906-0400 INFO: DatabaseLogging Database connection is paused [./database/database.connectionpaused.dat]
2022-03-23 15:43:51.053-0400 WARN: Event:DatabaseLogging 1648064631.053173 DatabaseLogging /geneos/gateway[@name="testing_gateway"] Connection Dropped [server01 geneos_db 3306 username:geneos_db_user]
```

To resume database logging, you can run the following command:

```
curl -u username:password -X POST -s --data '{ "command" : "/DATABASELOGGING:connection:resume", "target":" /geneos/gateway/directory[(rparam(\"DBConnectionPaused\")=\"true\")]"}' http://gatewayHost:gatewayPort/rest/runCommand
```

The gateway log will show the following lines saying the command has been executed and the database connection is resumed.

```
2022-03-23 15:58:28.682-0400 INFO: CommandManager Executing command [/DATABASELOGGING:connection:resume] with id [117] for request id [27]
2022-03-23 15:58:28.683-0400 INFO: CommandManager Executing command '/DATABASELOGGING:connection:resume' on DataItem '/geneos/gateway[(@name="testing_gateway")]/directory', issued by user 'username' on '192.168.x.xx' using REST service
2022-03-23 15:58:28.684-0400 INFO: CommandManager Received 0 arguments for command
2022-03-23 15:58:28.685-0400 INFO: DatabaseLogging Database connection is resumed
```

If you still see the database icon red and crossed out in the gateways dockable, and the connectionStatus still says `Not Connected` in the Summary view of the Gateway-databaseLogging plug-in, this is because the database is not logging anything new upon the database connection resuming.

As soon as a new item is logged to the database, the database icon will no longer appear crossed out and the connectionStatus will say `Connected`.

The gateway log will then show the following entry stating the database connection has been established:

```
2022-03-23 16:00:40.098-0400 INFO: Event:DatabaseLogging 1648065640.098452 DatabaseLogging /geneos/gateway[@name="testing_gateway"] Connection Established [server01 geneos_db 3306 username:geneos_db_user, serverVersion 5.1.44]
```

## Related documentation

- [Gateway-databaseLogging](https://docs.itrsgroup.com/docs/geneos/current/processing/data-access-and-publishing/geneos_dblogging_tr/index.html)
- [Rest Service/REST API](https://docs.itrsgroup.com/docs/geneos/current/processing/monitoring-and-alerts/geneos_commands_tr/index.html#rest-service)
- [Database Logging Commands](https://docs.itrsgroup.com/docs/geneos/current/processing/data-access-and-publishing/geneos_dblogging_tr/index.html#commands)


