> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# logsSubscribe | Solana

> Subscribe to real-time Solana log messages with logsSubscribe. Receive WebSocket notifications whenever new program logs are generated on-chain.

## Parameters

* `filter` - An object or string specifying the type of logs to receive:

  * `"all"` - Subscribe to all logs (string)
  * `{mentions: [<string>]}` - An array of public keys as base-58 encoded strings. Returns notifications only when the specified account or program ID is mentioned in the log.

* `<commitment>` - (optional) The level of commitment desired when querying state. Default is "finalized".

## Response

* `result` - An integer subscription id (needed to unsubscribe)

* `subscription` - An object containing log information:

  * `signature` - The transaction signature as base-58 encoded string
  * `err` - Error if transaction failed, null if transaction succeeded
  * `logs` - Array of string log messages

## `logsSubscribe` code examples

This example subscribes to all logs from the [pump.fun program](https://solscan.io/account/6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P).

<Info>
  Note that subscriptions require a WebSocket connection and [WebSocket cat](https://www.npmjs.com/package/wscat) for you to use this method in the console.

  Install WebSocket cat with:

  `npm install -g wscat`
</Info>

<CodeGroup>
  ```shell wscat theme={"system"}
  $ wscat -c YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT
  # Wait for the connection to be established

  Connected (press CTRL+C to quit)

  > {"jsonrpc":"2.0","id":1,"method":"logsSubscribe","params":[{"mentions":["6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"]},{"commitment":"finalized"}]}
  ```
</CodeGroup>

## Use case

The `logsSubscribe` method in Solana is used to subscribe to the network and receive real-time updates on new log messages. This can be useful in various real-world scenarios, including:

* Debugging and monitoring: Developers can use this method to receive instant notifications about log messages related to their applications, helping them debug issues and monitor performance in real-time.
* Event tracking: dApps can utilize this method to track specific events or actions on the blockchain by subscribing to logs mentioning particular accounts or programs.
* Analytics: Blockchain analytics services can use this subscription to gather real-time data about specific program executions, helping to provide insights into the usage and behavior of various Solana programs.
* Notification systems: Wallet providers or other services can use this method to notify users about specific events or transactions related to their accounts.

By subscribing to the `logsSubscribe` method, applications can receive instant updates about new log messages, allowing them to react quickly to events on the Solana blockchain and provide a more responsive user experience.
