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

# Logfmt Log Formatting

<Warning>
  🔐 Do not send <strong>Personal Identifiable Information (PII)</strong> to AppSignal. Filter PII (e.g., names, emails) from logs and use an ID, hash, or pseudonymized identifier instead. <br /> <br /> For **HIPAA-covered entities**, more information about signing a Business Associate Agreement (BAA) can be found in our [Business Add-Ons documentation](/support/business-add-ons).
</Warning>

Logfmt is a log format that is easy for humans to read and write, and is supported by AppSignal. It was initially used as the format for the [Heroku Logdrains](/logging/platforms/heroku), and is now used by many other logging providers.

Most of our platforms and endpoints support the Logfmt message format, which we'll describe in more detail below.

## Format

Logfmt is a key-value format, where each key-value pair is separated by a space. The key and value are separated by an equals sign (`=`). The key-value pairs are appended to the message at the end of the log line.

Any key-value pairs that do not follow the Logfmt format are appended to the message of the log line.

### Examples

The following examples show how AppSignal parses logs in the Logfmt format:

#### Message with attributes

<CodeGroup>
  ```shell Shell theme={null}
  this is foo=bar duration=10 a value="with spaces" message
  ```
</CodeGroup>

This will be parsed to a log line with the message `"this is a message"`, and the following attributes: `{ "foo": "bar", "duration": 10, "value": "with spaces"}`

#### Message with override

<CodeGroup>
  ```shell Shell theme={null}
  this is foo=bar a duration=10 message message="I am a message"
  ```
</CodeGroup>

This will be parsed to a log line with the message `"I am a message"`, and the following attributes: `{ "foo": "bar", "duration": 10 }`.

The rest of the original message is ignored, in favor of the `message` key.

#### Attributes only

<CodeGroup>
  ```shell Shell theme={null}
  foo=bar duration=100
  ```
</CodeGroup>

This will be parsed to a log line with the message `"foo=bar duration=100"`, and the following attributes: `{ "foo": "bar", "duration": 100 }`

## Formatting Rules

* Keys must be alphanumeric.
* Keys cannot contain spaces, but may contain full stops (`.`), underscores (`_`) and hyphens (`-`).
* Keys may not contain more than 50 characters
* Values must start with an alphanumeric character, and may not be longer than 100 characters
* No more than 25 attributes per log message.

Key value pairs that do not follow these rules are appended to the message of a log.

**Key behavior:**

* If a key does not have a value, it will be appended to the message field.
* If a key-value pair has a key with the name of `msg` or `message` the value of this key will be parsed as the log message.
* If no message/msg key is available, the entire log line will be considered the message.
