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

# Forward Upsun and Blackfire logs

> Send your Upsun and Blackfire logs to a third-party service for further analysis.

export const VariableBlock = ({name}) => {
  return <var spellCheck={false} title={`Replace '${name}' with your own data`}>{name}</var>;
};

export const SettingsIcon = () => <svg width="24px" height="24px" style={{
  display: 'inline',
  verticalAlign: 'middle'
}}>
    <title id="settings-icon">Settings</title>
    <path d="M10.5289 21.9416C9.86066 21.8582 9.3595 21.3576 9.19245 20.6903L9.02539 19.6892C8.85834 19.6058 8.77482 19.6058 8.60776 19.5224L7.93955 20.0229C7.43839 20.44 6.68665 20.44 6.10196 20.0229C6.10196 20.0229 4.09732 18.1042 4.01379 17.9374C3.51263 17.3535 3.51263 16.6027 3.93027 16.0187L4.51495 15.3514C4.43143 15.1845 4.43143 15.1011 4.3479 14.9343L3.42911 14.7674C2.76089 14.684 2.25973 14.1835 2.09268 13.4327C2.00915 13.1824 2.09268 10.4296 2.09268 10.4296C2.17621 9.76222 2.67737 9.2617 3.34558 9.09486L4.3479 8.92802C4.43143 8.8446 4.43143 8.76118 4.51495 8.59434L4.01379 7.92697C3.59616 7.42645 3.59616 6.67567 4.01379 6.09173C4.01379 6.09173 5.93491 4.08964 6.10196 4.00622C6.68665 3.5057 7.43839 3.5057 8.02307 3.9228L8.69129 4.50675C8.85834 4.42333 8.94187 4.42333 9.10892 4.33991L9.27597 3.42228C9.3595 2.75492 9.86066 2.2544 10.6124 2.08756C10.863 2.00414 13.2853 2.00414 13.5358 2.08756H13.6194C14.2876 2.17098 14.7887 2.6715 14.9558 3.33886L15.1228 4.33991C15.2064 4.42333 15.2899 4.50675 15.457 4.50675L16.1252 4.00622C16.6263 3.58912 17.3781 3.58912 17.9628 4.00622C17.9628 4.00622 19.9674 5.92489 20.0509 6.09173C20.5521 6.67567 20.5521 7.42645 20.1344 8.0104L19.6333 8.67776C19.7168 8.8446 19.7168 9.01144 19.8003 9.09486L20.7191 9.2617C21.3873 9.34512 21.972 9.92906 22.0556 10.5964V13.5996C21.972 14.2669 21.4709 14.7674 20.8027 14.9343L19.8003 15.1011C19.7168 15.268 19.7168 15.3514 19.6333 15.5182L20.218 16.269C20.6356 16.7695 20.6356 17.5203 20.218 18.1042L18.0463 20.2732C17.4616 20.6903 16.7099 20.6903 16.2087 20.2732L15.3734 19.6058C15.2064 19.6892 15.1228 19.6892 14.9558 19.7726L14.7887 20.6903C14.7052 21.3576 14.1205 21.9416 13.4523 22.025H10.5289V21.9416ZM11.5312 20.3566C11.8653 20.3566 12.1994 20.3566 12.45 20.3566C12.8676 20.3566 13.2017 20.0229 13.2853 19.6058L13.3688 18.9384C13.3688 18.6882 13.6194 18.4379 13.8699 18.2711L15.1228 17.7706C15.3734 17.6871 15.7075 17.6871 15.9581 17.854L16.5428 18.2711C16.8769 18.5213 17.3781 18.5213 17.6286 18.1877C17.7957 18.0208 18.0463 17.7706 18.2969 17.5203C18.5474 17.1866 18.631 16.7695 18.3804 16.4358L17.8792 16.0187C17.7122 15.7685 17.6286 15.4348 17.7957 15.1845L18.2969 14.0167C18.3804 13.7664 18.631 13.5996 18.9651 13.5161L19.6333 13.4327C20.0509 13.3493 20.385 13.0156 20.385 12.5985C20.385 12.2648 20.385 11.9311 20.385 11.6809C20.385 11.2638 20.0509 10.9301 19.6333 10.8467L18.9651 10.7633C18.7145 10.7633 18.4639 10.513 18.2969 10.2627L17.7957 9.01144C17.7122 8.76118 17.7122 8.4275 17.8792 8.17724L18.2969 7.59329C18.5474 7.25961 18.5474 6.84251 18.2133 6.50883C18.0463 6.34199 17.7957 6.09173 17.5451 5.84147C17.211 5.50779 16.7934 5.50779 16.4593 5.75805L16.0416 6.17515C15.7911 6.34199 15.457 6.42541 15.2064 6.25857L14.037 5.75805C13.7864 5.67463 13.6194 5.42437 13.5358 5.09069L13.3688 4.50675C13.2853 4.08964 12.9511 3.75596 12.5335 3.75596C12.1994 3.75596 11.8653 3.75596 11.6147 3.75596C11.1971 3.75596 10.863 4.08964 10.7795 4.50675L10.6959 5.17411C10.6959 5.42437 10.4453 5.67463 10.1948 5.84147L9.02539 6.25857C8.69129 6.42541 8.44071 6.34199 8.19013 6.17515L7.60544 5.75805C7.27133 5.50779 6.77017 5.50779 6.51959 5.84147C6.26901 6.00831 6.10196 6.25857 5.85138 6.42541C5.6008 6.75909 5.51727 7.17619 5.85138 7.50987L6.18549 8.09382C6.35254 8.34408 6.43607 8.67776 6.26901 8.92802L5.76785 10.0959C5.68433 10.3462 5.43375 10.513 5.09964 10.5964L4.43143 10.6798C4.01379 10.7633 3.67969 11.0969 3.67969 11.514C3.67969 11.8477 3.67969 12.1814 3.67969 12.4317C3.67969 12.8488 4.01379 13.1825 4.43143 13.2659L5.09964 13.3493C5.35022 13.3493 5.6008 13.5996 5.76785 13.8498L6.26901 15.1011C6.35254 15.3514 6.35254 15.6851 6.18549 15.9353L5.76785 16.5193C5.51727 16.8529 5.51727 17.3535 5.85138 17.6037C6.01843 17.7706 6.26901 18.0208 6.51959 18.2711C6.8537 18.5213 7.27133 18.6048 7.60544 18.3545L8.02307 17.854C8.27365 17.6871 8.60776 17.6037 8.85834 17.7706L10.0277 18.2711C10.2783 18.3545 10.4453 18.6048 10.5289 18.9384L10.6124 19.6058C10.7795 20.0229 11.1136 20.3566 11.5312 20.3566ZM18.798 6.92593C18.798 6.92593 18.798 7.00935 18.798 6.92593V6.92593Z"></path>
    <path d="M12.0324 17.0198C9.27597 17.0198 7.02075 14.7675 7.02075 12.0146C7.02075 9.26172 9.27597 7.00937 12.0324 7.00937C14.7887 7.00937 17.044 9.26172 17.044 12.0146C17.044 14.7675 14.7887 17.0198 12.0324 17.0198ZM12.0324 8.67777C10.1948 8.67777 8.69129 10.1793 8.69129 12.0146C8.69129 13.8498 10.1948 15.3514 12.0324 15.3514C13.8699 15.3514 15.3734 13.8498 15.3734 12.0146C15.3734 10.1793 13.8699 8.67777 12.0324 8.67777Z"></path>
  </svg>;

You might use a service to analyze logs from various parts of your fleet.
You might want to consolidate all your logs in one place that everyone has access to
without needing to grant them access to each project individually.

In such cases, forward your logs from Upsun and Blackfire to a third-party service.
You can use a [service with an integration](#use-a-log-forwarding-integration)
or any service that supports a [syslog endpoint](#forward-to-a-syslog-endpoint) or [HTTP endpoint](#forward-to-an-http-endpoint).

Log forwarding is available for Grid projects.
For Dedicated Gen 2 projects, see how to [log remotely with `rsyslog`](https://docs.platform.sh/dedicated-gen-2/architecture/options.html#remote-logging).
To enable log forwarding in a project, you need to be a [project admin](/docs/administration/users).
For pricing information for real-time logs forwarding, refer to the **Observability and performance monitoring** section of the [Upsun pricing page](https://upsun.com/pricing/).

### Which logs are forwarded?

When log forwarding is enabled, Upsun forwards logs sent to journald.

By default, Upsun sends the following logs to journald:

* `stdout` and `stderr` logs from your application<br />
  Note: You can configure your application to use syslog to send these (or additional) messages to journald.
* MariaDB/MySQL slow query logs
* Redis logs (all except command-level operations and low-level internals)

Logs in files are not forwarded to journald.

## Use a log forwarding integration

Certain services have a specific integration for forwarding logs.
If your third-party service isn't supported, you can forward to a [syslog endpoint](#forward-to-a-syslog-endpoint).

### Integrated third-party services

Upsun supports forwarding logs not only to custom remote syslog endpoints but also directly to a set of
popular third‑party log management and observability services. These integrations allow you to centralize logs from
applications, services, and infrastructure into your existing monitoring stack:

* **[Sumo Logic](https://www.sumologic.com/)** – Cloud-based log management and analytics.
* **[New Relic](https://newrelic.com/)** – Unified observability platform with logs and metrics.
* **[Splunk](https://www.splunk.com/)** – Searchable log platform for monitoring and operational intelligence.
* **[Datadog](https://www.datadoghq.com/)** – Observability suite with log collection and processing.
* **[Loggly](https://www.loggly.com/)** – Cloud-native log monitoring, aggregation, and alerting.
* **[LogDNA (Mezmo)](https://www.mezmo.com/)** – Centralized log management and analysis in real time.
* **[Papertrail](https://www.papertrail.com/)** – Real-time log aggregation via syslog.
* **[Logz.io](https://logz.io/)** – ELK-based log analytics and monitoring.

### Enable a log forwarding integration

#### Using the CLI

To enable log forwarding for a specific project using the [Upsun CLI](/cli),
follow the steps for your selected service.

<Tabs>
  <Tab title="New Relic">
    1. Get an API key from New Relic.
       You need a [license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#license-key).
       Your New Relic organization likely has one, but you can create one by following the New Relic docs.
    2. Choose an API endpoint.
       You can use the U.S. endpoint `https://log-api.newrelic.com/log/v1`
       or the EU endpoint `https://log-api.eu.newrelic.com/log/v1`.
    3. Create the integration with the following command:

       ```bash theme={null}
       upsun integration:add --type newrelic --url <API_ENDPOINT> --license-key <LICENSE_KEY>
       ```

    View your logs in the **Logs** dashboard.
  </Tab>

  <Tab title="Splunk">
    1. In Splunk, get an Event Collector token on [Splunk Platform](https://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector#Create_an_Event_Collector_token_on_Splunk_Cloud_Platform)
       or [Splunk Enterprise](https://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector#Create_an_Event_Collector_token_on_Splunk_Enterprise).
    2. Determine your host, which is the Splunk instance that's collecting data.
    3. Choose an index name.
    4. Create the integration with the following command:

       ```bash theme={null}
       upsun integration:add --type splunk --url https://http-inputs.<HOST>.splunkcloud.com/services/collector/event --index <INDEX> --token <TOKEN>
       ```

    View your logs in the **Apps->Search & Reporting** dashboard.
    Filter by the index name to find the relevant events.
  </Tab>

  <Tab title="Sumo Logic">
    1. In Sumo Logic, [configure an HTTP source](https://www.sumologic.com/help/docs/send-data/hosted-collectors/http-source/logs-metrics/#configure-an-httplogs-and-metrics-source).
       Make sure to copy the Source Category and collector URL.
    2. Create the integration with the following command:

       ```bash theme={null}
       upsun integration:add --type sumologic --url <COLLECTOR_URL> --category <SOURCE_CATEGORY>
       ```

    View your logs in the **Log Search** tab.
  </Tab>
</Tabs>

To start forwarding logs, [trigger a redeploy](/docs/troubleshooting/general#force-a-redeploy).

#### In the Console

To enable log forwarding for a specific project from the Console,
follow these steps:

1. Navigate to your project.
2. Click <SettingsIcon /> **Settings**.
3. Click **Integrations**.
4. Click **Add Integration**.
5. Select the integration you want to enable.
6. In the **Configure your integration** window,
   specify your configuration options.
7. Click **Add Integration**.
   The new integration overview is displayed,
   and you can view your logs in the **Activity** section.

## Forward to a syslog endpoint

Syslog is a standard protocol for transferring log messages.
Many third-party services offer endpoints for ingesting syslog events.
You can forward your Upsun and Blackfire logs to any of those endpoints.

<Tabs>
  <Tab title="Using the CLI">
    To enable log forwarding to a syslog endpoint,
    run a command similar to the following:

    ```bash theme={null}
    upsun integration:add --type syslog --syslog-host <INGESTION_HOST> --syslog-port <INGESTION_HOST_PORT>
    ```

    `type`, `syslog-host`, and `syslog-port` are the only properties required for all endpoints.
    The following table shows the other available properties:

    | Property         | Type      | Default    | Description                                                                                                                                           |
    | ---------------- | --------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `auth-token`     | `string`  |            | The token to authenticate with the given service.                                                                                                     |
    | `auth-mode`      | `string`  | `prefix`   | The mode for authentication with the given service. Can be `prefix` or `structured_data`. Defaults to `prefix`.                                       |
    | `facility`       | `string`  | `1` (user) | A [syslog facility code](https://en.wikipedia.org/wiki/Syslog#Facility) to attach with each log to identify the source. Can be a number from 0 to 23. |
    | `message-format` | `string`  | `rfc5424`  | The standard to use for the message format. Can be `rfc5424` or `rfc3164`.                                                                            |
    | `protocol`       | `string`  | `tls`      | The network protocol to use in the connection. Can be one of `tls`, `tcp`, or `udp`. Defaults to `tls`.                                               |
    | `verify-tls`     | `boolean` | `true`     | Whether to verify Transport Layer Security (TLS) certification when using the TLS protocol.                                                           |

    To include a property, add it as a flag, for example `--protocol tcp`.
    This should let you connect to any service that has syslog endpoints.

    To start forwarding logs, once you've added the service [trigger a redeploy](/docs/troubleshooting/general#force-a-redeploy).
  </Tab>

  <Tab title="In the Console">
    To enable log forwarding to a syslog endpoint for a specific project using the [Upsun CLI](/cli),
    follow these steps:

    1. Navigate to your project.
    2. Click <SettingsIcon /> **Settings**.
    3. Click **Integrations**.
    4. Click **Add Integration**.
    5. Select the syslog integration.
    6. In the **Configure your integration** window,
       specify your configuration options.
    7. Click **Add Integration**.
       The new integration overview is displayed,
       and you can view your logs in the **Activity** section.
  </Tab>
</Tabs>

## Forward to an HTTP endpoint

Some third-party services, such as [Elasticsearch](/docs/add-services/elasticsearch) and [OpenSearch](/docs/add-services/opensearch),
support ingesting log messages through an HTTP endpoint.
You can use HTTP forwarding to forward Upsun and Blackfire logs to such third-party services.

HTTP forwarding makes a `POST` HTTP request with an `application/json` body while forwarding the log messages to the endpoint.

As an example, to forward logs to Elasticsearch using HTTP log forwarding, run the following command:

```
upsun integration:add --type httplog --url "https://<ELASTICSEARCH_URL>/<INDEX_NAME>/_doc" --header "Authorization: Basic <basic_auth_token>" --header "Content-Type: application/json"
```

`type` and `url` are the only properties required for all endpoints.
Optionally, you can use the `headers` property to pass additional headers in the HTTP requests.

Note that if your endpoint URL includes a `PORT`, that can also be included in the `--url` flag:

```
upsun integration:add --type httplog --url "https://<ELASTICSEARCH_URL>:<PORT>/<INDEX_NAME>/_doc" --header "Authorization: Basic <basic_auth_token>" --header "Content-Type: application/json"
```

Once you've [added the service](/docs/add-services),
to start forwarding logs [trigger a redeploy](/docs/troubleshooting/general#force-a-redeploy).

## Log levels

Your app may output logs with distinct severity levels.
But as Upsun only reads logs from `stdout`,
this distinction is lost and everything gets logged at `INFO` level.

To preserve the original log level, use a language-specific syslog module/package for logging.

The following example code snippets show how logs can be written to Syslog:

<Tabs>
  <Tab title="PHP">
    ```php theme={null}
    openlog("", LOG_PID, LOG_LOCAL0);
    syslog(LOG_INFO, "Operation started");
    syslog(LOG_ERR, "Operation failed");
    closelog();
    ```
  </Tab>

  <Tab title="Python">
    Using the logging module:

    ```python theme={null}
    import logging
    import logging.handlers

    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)
    handler = logging.handlers.SysLogHandler(address="/dev/log")
    logger.addHandler(handler)

    logger.info("Operation started")
    logger.error("Operation failed")
    ```

    Using the Syslog module:

    ```python theme={null}
    import syslog

    syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_LOCAL0)
    syslog.syslog(syslog.LOG_INFO, "Operation started")
    syslog.syslog(syslog.LOG_ERR, "Operation failed")
    syslog.closelog()
    ```
  </Tab>

  <Tab title="Go">
    Using the log package:

    ```go theme={null}
    package main

    import (
    	"log"
    	"log/syslog"
    )

    func main() {
    	logger, err := syslog.NewLogger(syslog.LOG_LOCAL0|syslog.LOG_INFO, log.LstdFlags)
    	if err != nil {
    		panic(err)
    	}

    	logger.Println("Operation started...")
    	logger.Fatalln("Operation failed")
    }

    ```

    Using the Syslog package:

    ```go theme={null}
    package main

    import (
    	"fmt"
    	"log"
    	"log/syslog"
    )

    func main() {
    	syslogWriter, err := syslog.Dial("", "", syslog.LOG_LOCAL0|syslog.LOG_INFO, "")
    	if err != nil {
    		log.Fatal(err)
    	}
    	defer syslogWriter.Close()

    	fmt.Fprintf(syslogWriter, "Operation has started")
    	syslogWriter.Err("Operation failed")
    }
    ```
  </Tab>
</Tabs>
