# Moving from Better Stack

Tailcove takes Better Stack (Logtail) client batches at `https://ingest.tailcove.dev/api/v1/betterstack`, in both
encodings their libraries use: JSON (PHP, Go, plain HTTP) and MessagePack (Node, Python, Ruby). Change the client's
endpoint and its token, and nothing else.

The token is your Tailcove source's **ingest token**, sent the way the client already sends it
(`Authorization: Bearer`).

## Node.js

```js
import { Logtail } from "@logtail/node";

const logtail = new Logtail("YOUR_INGEST_TOKEN", {
  endpoint: "https://ingest.tailcove.dev/api/v1/betterstack",
});
```

## Python

```python
from logtail import LogtailHandler

handler = LogtailHandler(
    source_token="YOUR_INGEST_TOKEN",
    host="https://ingest.tailcove.dev/api/v1/betterstack",
)
```

## Laravel and Monolog

In `config/logging.php`, keep the Better Stack channel and change its endpoint:

```php
'betterstack' => [
    'driver' => 'monolog',
    'handler' => Logtail\Monolog\LogtailHandler::class,
    'handler_with' => [
        'sourceToken' => env('TAILCOVE_TOKEN'),
        'endpoint' => 'https://ingest.tailcove.dev/api/v1/betterstack',
    ],
],
```

For a new Laravel app, the [Tailcove package](https://tailcove.dev/docs/sending-logs/laravel-package) does more (request ids, failed
jobs, slow queries, secrets masked before they leave the server).

## Send to both first

Most loggers can have two handlers. Add a second client pointed at Tailcove and leave the Better Stack one in
place; in Laravel, put both channels in `LOG_STACK`. Remove the old one once you've compared them for a while.

## What arrives

`dt` is the line's time, `level` its level and `message` its message. Everything else the client sent (`context`,
`extra`, your own fields) is kept under the same names, so a field you searched for in Better Stack is a field here
too. The host is taken from `context.system.hostname` when the client adds it.

We built this against the formats the Better Stack libraries send. Before you switch the old one off, check that a
few lines from each app arrive the way you expect.
