# Your own log formats (Custom Format Studio)

TKTail knows 35+ formats ([Built-in formats](https://tktail.dev/help/built-in-formats/) lists every one). When yours
is not one of them - a proprietary application log, an in-house service, a device - you can
teach TKTail the format yourself, without programming.
A **custom format** (a *profile*) describes it, and TKTail then treats it like a built-in
format:
- it detects files in it automatically;
- it splits records into fields with meanings (time, severity, component, message ...);
- the RECORD view shows a Summary and the Fields; the Inspector shows the current record;
- structured search and alert conditions (`level = ERROR`, `payment = 9921`) work on its
  fields;
- the viewer colours timestamps, levels and numbers.

The **Custom Format Studio** edits a profile with a live preview of every change.

**A profile is data, never code.**
- It holds patterns (regular expressions), field names, meanings and simple conditions such as
  `level = ERROR`.
- Nothing in a profile can run PowerShell, a shell command, JavaScript, a DLL or any other
  program.
- An imported profile is checked before it can be used.

The reference of every setting is CUSTOM_FORMATS.md.

## Opening the Studio

- **View > View As > Create Format for This Log...** - a new profile with up to 50 records of the
  current log (from the record you are on, at most 16,000 characters) as its sample; for a log whose
  records already span several lines the template proposed is the multi-line one, for a CSV / TSV /
  pipe file the delimited one - already set to the file's separator, with one field per column
  ([Delimited files](https://tktail.dev/help/custom-formats/#delimited-files)).
- **Tools > Custom Format Studio...**. (**Use For > Favorite Format** there lists a saved profile among
  your favorite formats - first in View As.) It opens the profile of the active file, if the file uses
  one; otherwise it starts a new profile.
- **View > View As > Custom** (also in the viewer's context menu):
  - **New Custom Format...** offers four templates:
    - *Line-based*: one record per line - timestamp, level, message.
    - *Multi-line records*: a record starts at a line with a date; the lines after it belong to
      it.
    - *Clone built-in: Application log*: TKTail's application-log format as an editable
      profile.
    - *Delimited columns*: CSV, TSV, `;` or `|` separated files - one record per line, fields read
      columns.
  - **Edit This Custom Format...** edits the profile of the active file.
  - **Clone Built-In: Application Log...** starts from the application-log clone at once.
  - A new profile - from a template, the clone or **Save as Copy** - has **no detection rules**:
    it is used where you choose it (the list below, **Use For**, a `.tktail`) and never takes
    over other logs by itself. Add *Extensions*, *File names* or a *Content pattern* under
    *Detection* when files should pick it automatically ([below](https://tktail.dev/help/custom-formats/#which-files-use-a-profile)).
  - The list in this submenu also chooses a profile by hand for the active file.
  - **Reload Custom Formats** reads the profiles again; **Open Custom Formats Folder** opens
    where they are stored.

A new profile's id and name come from the active file's name, for example `billing` and
*billing format*. Without an open file they are `my-format`.

## How a profile reads a record

Every record goes through the same steps, in the Studio's preview and in the viewer alike:

1. **Framing** - one line is one record, or a record starts at a line matching *Record start*
   and the following lines (a stack trace, a payload) belong to it until the next record start
   ([Multi-line records](https://tktail.dev/help/custom-formats/#multi-line-records)).
2. **Common pattern** - one regular expression with named groups reads the parts every record
   has (`(?<timestamp>...)`, `(?<level>...)`, `(?<message>...)`). It is matched against the
   record's first line.
3. **Record type** - optional kinds of records (*Payment failed*, *Retry* ...), tried in order
   of priority; the first that matches wins; a **fallback** type takes everything else.
4. **Type-specific extraction** - a record type can read more fields from a field (for example
   `message`) or from the whole record.
5. **Conditions** - a field can exist only when a condition is true (`level = ERROR`).
6. **Semantic roles** - each field can say what it means: timestamp, severity, message ...
7. **Presentation** - which fields the RECORD view's Summary shows, and how.
8. **Highlighting** - the viewer colours fields by their role and type: severities by level,
   timestamps, numbers.

## The Studio window

- **DEFINITION** (left) - the parts of the profile as a tree: *General*, *Detection*,
  *Framing*, *Common pattern*, *Common fields*, *Record types* (each with its own fields),
  *Semantics (severity names)*, *Summary*, *Sample*. Select one to edit it below the tree.
  - **Add Field** adds a field to the selected record type, or to the common fields.
  - **Add Record Type** adds a type before the fallback.
  - **Clone Type** copies the selected type.
  - **Remove** deletes the selected field or type.
- **PIPELINE** - what happened to the sample, step by step: was it detected, how it is framed
  into records, did the common pattern match, which record type was chosen (and which others
  matched too, or the fallback), which fields were extracted, omitted by a condition or kept raw.
  For multi-line framing it ends with every record of the sample and its source lines
  (*Record 1 - lines 1-4*). Clicking a step selects the part of the definition it is about.
- **SOURCE** - the sample, coloured by what each field captured. Clicking text selects the
  field it belongs to.
- **RECORD** - **Summary** shows the record exactly as the RECORD view will show it; **Fields**
  lists every field with its value, where it comes from (common or the record type), its role,
  type and state.
- **DIAGNOSTICS** - every mistake and warning. Clicking one goes to the part it is about.
- The status line says how long the preview took, and whether the draft is saved.

*Screenshot: The Custom Format Studio: Create Format for This Log on an application log*

**Live preview.** The Studio uses TKTail's real parser, the same code the viewer uses - there is
no separate "preview parser". Each change is applied to the sample about 200 ms after you stop
typing, in the background; the window never freezes.

A pattern row tells you at once whether the pattern is valid and which groups it captures
(*valid - 4 groups: timestamp, level, component, message*), or what is wrong and where. A
condition row says whether it is valid and, when it is, whether it is true for the sample.

## Draft and saved profile

**You always edit a draft. Files open in TKTail keep using the saved profile until you click
Save.** A half-typed pattern can therefore never disturb monitoring or alerts.

- **Save** checks the draft. If it has errors, nothing is saved - the status line says how many,
  DIAGNOSTICS lists them, and the saved version stays in use.
- A valid draft is written safely: a temporary file, then a rename, so it is never half
  written. Open files using the profile switch to the new version at once (*Saved - applied to
  N open files*).
- **Revert** goes back to the saved version (the samples stay as they are).
- **Use For** (a saved profile without unsaved changes) makes files use it without detection:
  **Apply to Current File**, **Set as Folder Default** (the current file's folder and its
  subfolders) or **Add Folder Rule...** (a pattern such as `*.txt`). These write a
  [folder format file](https://tktail.dev/help/local-configuration/) (`.tktail`) beside the logs that names the profile
  by its id (`custom:<id>`), so renaming the profile later keeps them working. Nothing is stored
  anywhere else.
- Closing the Studio with unsaved changes asks **Save** / **Discard** / Cancel. Exiting TKTail
  counts an unsaved draft in its exit question.

## Walkthrough: a `timestamp | level | component | message` log

The log (synthetic, `billing-2026-10-05.log`):

```
2026-10-05 09:15:02.114 | INFO  | Billing.Invoices | Invoice 4711 created for account 8812
2026-10-05 09:15:02.381 | WARN  | Billing.Payments | Retry 2 for payment 9921 after 1500 ms
2026-10-05 09:15:03.007 | ERROR | Billing.Payments | Payment 9921 failed: card declined
2026-10-05 09:15:03.250 | INFO  | Billing.Invoices | Invoice 4712 created for account 8813
```

1. **Open the file** in TKTail, then **View > View As > Custom > New Custom Format...** and
   choose **Line-based**. If the sample is empty, click **Use Current Line**. The PIPELINE says
   the common pattern does not match - the template expects `timestamp level message`, not
   pipes.
2. **Common pattern**: replace it with
   `^(?<timestamp>\d{4}-\d{2}-\d{2} [\d:.]+) \| (?<level>[A-Z]+) *\| (?<component>[^|]+?) \| (?<message>.*)$`.
   The row says *valid - 4 groups*, and SOURCE colours the four parts.
3. **Common fields**: the template has `timestamp`, `level` and `message`. Select *Common
   fields* and **Add Field**; set its id and capture group to `component` and its role to
   *logger*. RECORD > Summary now shows *INFO · Invoices* with the message.
4. **Record types**:
   - **Add Record Type** `PAYMENT_FAILED`, priority 100:
     - *Match in* `message`, *Match pattern* `^Payment \d+ failed`;
     - *Extract from* `message`, *Extract pattern*
       `^Payment (?<payment>\d+) failed: (?<reason>.*)$`;
     - add its fields `payment` (type integer, role correlation) and `reason`.
   - Add `RETRY` (priority 90) the same way:
     - match `^Retry `;
     - extract `^Retry (?<attempt>\d+) for payment (?<payment>\d+) after (?<delay>\d+) ms`;
     - `delay` has type *durationMs* and role *duration*.
   - Add a type `RECORD` with **Fallback** for everything else.
5. **Summary**:
   - *Status badge* `level`, *Title fields* `component`, *Message* `message`;
   - *Primary fields* `payment, reason, attempt, delay`; *Details* `timestamp`.

   For the retry line, the Summary shows the *WARN* badge, the title *Billing.Payments*, the
   message, and the rows *Payment 9921*, *Attempt 2* and *Delay 1.50 s (1500)*.
6. **Detection**:
   - *File names* `billing*.log`;
   - *Content pattern* `^\d{4}-\d{2}-\d{2} [\d:.]+ \| `;
   - *Matching lines* `2`.
7. **Samples**: in *Sample*, **Add Line** for each kind of record and set its *Expected type*.
   **Test All** reports *4 samples · 4 detected · 4 classified correctly · 0 fallback · 0 parse
   errors*, PASS for each.
8. **Save**. The open file switches to the profile at once; the status bar shows *Billing
   service log*, and `level = ERROR` or `payment = 9921` work in search and alert conditions.

The resulting profile (`billing.tktformat.json`) - it passes `tktail formats custom validate`:

```json
{
  "schemaVersion": 1,
  "id": "billing",
  "name": "Billing service log",
  "description": "timestamp | level | component | message",
  "fileMatch": { "names": ["billing*.log"], "content": "^\\d{4}-\\d{2}-\\d{2} [\\d:.]+ \\| ", "minLines": 2 },
  "framing": { "kind": "line" },
  "envelope": { "pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2} [\\d:.]+) \\| (?<level>[A-Z]+) *\\| (?<component>[^|]+?) \\| (?<message>.*)$" },
  "fields": [
    { "id": "timestamp", "group": "timestamp", "type": "timestamp", "role": "timestamp" },
    { "id": "level", "group": "level", "role": "severity" },
    { "id": "component", "group": "component", "role": "logger" },
    { "id": "message", "group": "message", "role": "message" }
  ],
  "recordTypes": [
    { "id": "PAYMENT_FAILED", "name": "Payment failed", "priority": 100,
      "match": { "field": "message", "pattern": "^Payment \\d+ failed" },
      "extract": { "field": "message", "pattern": "^Payment (?<payment>\\d+) failed: (?<reason>.*)$" },
      "fields": [ { "id": "payment", "group": "payment", "type": "integer", "role": "correlation" },
                  { "id": "reason", "group": "reason" } ] },
    { "id": "RETRY", "name": "Retry", "priority": 90,
      "match": { "field": "message", "pattern": "^Retry " },
      "extract": { "field": "message", "pattern": "^Retry (?<attempt>\\d+) for payment (?<payment>\\d+) after (?<delay>\\d+) ms" },
      "fields": [ { "id": "attempt", "group": "attempt", "type": "integer" },
                  { "id": "payment", "group": "payment", "type": "integer", "role": "correlation" },
                  { "id": "delay", "group": "delay", "type": "durationMs", "role": "duration" } ] },
    { "id": "RECORD", "name": "Log record", "fallback": true }
  ],
  "presentation": { "summary": { "status": "level", "title": ["component"], "headline": "message",
                                 "rows": ["payment", "reason", "attempt", "delay"], "secondary": ["timestamp"] } }
}
```

## Multi-line records

In many logs one entry spans several lines: an error with its exception and stack trace, a
request with a JSON payload. TKTail calls each physical line a **source line** and each log entry
a **record**. Framing decides which source lines form one record. The Inspector, the RECORD view
and *Copy Current Record* then work on the whole record, whichever of its lines the caret is on.

**Framing** in the DEFINITION tree has these settings:

| Setting | Meaning |
|---|---|
| **Records** - *One line = one record* | Every line is its own record. |
| **Records** - *Multi-line: a new record at each record start* | A line matching **Record start** begins a new record. Every line after it belongs to that record until the next record start: exceptions, stack frames, payloads, text. |
| **Record start** | A regular expression for the first line of a record. Make it strict: a timestamp *and* a level, not just "a line with a date", so that text inside a payload does not start a record. |
| **Continuation** (optional) | When set, only lines matching it continue a record. A line that matches neither pattern becomes a record of its own. Leave it empty in most cases. |
| **Max lines**, **Max bytes** | Safety limits for one record. A longer run is split there; no line is lost. The viewer never joins more than 2,000 lines / 4 MB, whatever the profile says. |

### Example: an error with a stack trace

The log:

```
2026-10-05 07:15:11 ERROR MyService Request failed
System.Exception: Something happened
   at MyService.Work()
   at MyService.Run()
2026-10-05 07:15:12 INFO MyService Request completed
```

1. **View > View As > Custom > New Custom Format...**, template *Multi-line records*.
2. Select **Framing**. *Records* is already *Multi-line: a new record at each record start*.
3. Set **Record start** to a line that begins with a date, a time and a level:
   ```
   ^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (TRACE|DEBUG|INFO|WARN|ERROR|FATAL)
   ```
   (with the space at the end). The row under it says *valid - 1 group*.
4. Paste the log as the sample (**Paste Sample**). PIPELINE shows how it is framed:
   ```
   ✓ Framing      2 records: lines 1-4, line 5
     ...
   → Record 1     lines 1-4 · 4 source lines · previewed
          1  2026-10-05 07:15:11 ERROR MyService Request failed
          2  System.Exception: Something happened
          3     at MyService.Work()
          4     at MyService.Run()
   → Record 2     line 5 · 1 source line
          5  2026-10-05 07:15:12 INFO MyService Request completed
   ```
   The first record is the one previewed in SOURCE and RECORD; the steps between *Framing* and
   *Record 1* (common pattern, record type, fields, Summary) are about it.
5. Select **Sample** and set **Expected records** to `2`. **Test All** now fails if a change
   to the profile frames the sample differently, for example *expected 2 records, got 5*.

The same profile in the viewer: with the caret on `at MyService.Work()`, the Inspector and the
RECORD view show the 4-line ERROR record, and *Copy Current Record* copies those four lines.

*Screenshot: The Studio with the example as its sample (here opened with Create Format for This Log on it): Framing finds 2 records, Record 1 lists its four source lines*

### What PIPELINE warns about

| Message | What it means |
|---|---|
| *no line matches the record start - the whole sample would be one record* | The Record start pattern matches nothing; every line would join one record. |
| *the first line is a continuation - in a file it would join the previous record (orphan continuation)* | The sample starts in the middle of a record (for example with a stack frame). Add the record's first line, or check the pattern. |
| *a record reaches Max lines (n) - it is split there* | A record is longer than *Max lines*; raise it if that is normal for your log. |
| *every line starts a record - is the record start pattern too broad?* | The pattern also matches stack frames or payload lines. Make it stricter (add the level). |

Search and alerts still work line by line. A search hit on a stack frame takes you to that line,
and the Inspector shows the record it belongs to. An alert fires on the line that matches.

## Delimited files

Comma-, semicolon-, TAB- and pipe-separated files open without a profile (the built-in CSV, TSV and
pipe formats). Make a profile when such a file needs names, roles, types or record types - for
example a Qlik export whose `Sales` column should be a field with its own name:

1. Open the file and choose **View > View As > Create Format for This Log...** (template *Delimited
   columns*, offered first for such a file). The draft already uses the file's separator - say
   *Semicolon (;)* - and has one field per column, named from the header line. A sample taken from the
   middle of the file (this command, **Use Current Line**, **Use Current Record**) starts with the
   file's header line, so the preview names the columns as the file does - the sample's name says
   *(with the header line)*.
2. Under **Framing**, *Records* is *Delimited*. *Delimiter* (Comma, Semicolon, Tab, Pipe), *Quote*
   (a double or single quote, or none), *Quote escape* (`""` or `\"`) and *Header line* (the first
   line names the columns) are the profile's own settings - the PREVIEW reads the sample again as
   soon as you change one, before anything is saved.
3. A field reads a column: *Capture group* `3` is the third column, `Sales` the column the header
   line names *Sales* (with *Header line* on). Changing the delimiter never requires changing the
   fields.
4. **Save**. The separator is saved in the profile (`"delimiter": ";"`), exported and imported with
   it, and used for every file the profile is chosen for.

A short line leaves its last columns out (those fields are *not captured*). A quoted value that
contains a line break is not joined into one record.

### Recipe: a profile over a detected CSV

An export TKTail already opens as **CSV (semicolon)** - `Id;Customer;Time;Amount;Level;Region;Message` - should
have its time, level and message understood: time-ordered navigation, severity colours, `severity <= error`
searches and alerts.

1. Open the file, **View > View As > Create Format for This Log...**. The draft has the file's delimiter, quote and
   header line and seven fields, one per column (`Id` ... `Message`), each reading its column by number.
2. Select the **Time** field: *Type* Timestamp, *Semantic role* Timestamp - the draft already sets both when the
   header says `Time` (or `Timestamp`, `Date`). Its *Capture group* is `3`, the third column; with a header line the
   header's name `Time` works too.
3. **Level**: *Semantic role* Severity (set from the header `Level`; rename the field if you like -
   `severity_level` - the column stays the same). **Message**: *Semantic role* Message. Other header names get no
   role: set it yourself (a column called `Sev` is your severity).
4. The PREVIEW shows each record's time, severity and message at once. **Save**.
5. Make the file use it every time: **Use For > Apply to Current File** (a `.tktail` rule beside the file), or
   under **Detection** add the file's name (`export-*.csv`) to *File names*.

After a restart the file opens in your profile (the status bar names it), records have their time and severity,
and searches such as `severity_level = ERROR` or `severity <= error` use the columns. The same steps work for comma,
TAB and pipe files, with or without a header line (without one, fields read columns by number).

## Which files use a profile

- **Detection** in a profile has *Extensions* (`.log`), *File names* (wildcards such as
  `billing*.log`), a *Content pattern* tested on the file's first lines, and *Matching lines*:
  how many of up to 64 first lines must match.
- A profile that names files (extensions or names) and matches the file - and its content
  pattern, if it has one - is a **strong** match. It wins over TKTail's built-in detection.
- A profile without file names whose content pattern matches is a **weak** match. It is used
  only when the built-in detection finds nothing.
- A profile with no detection rules is never chosen automatically - only by hand. Templates,
  the clone and **Save as Copy** make such profiles; the detection rules are yours to add.
- Name files narrowly: a profile for `.log` files whose lines start with a date would also claim
  an IIS log or any other dated log - when it wins over a confident built-in detection, the Format
  tooltip says *Content detector disagrees* and names what the content looks like.
- Among several matching profiles, the higher **priority** wins (General), then the file name.

The order TKTail follows for every file:
1. A format you chose with **View As** (or `--format`).
2. A [folder format](https://tktail.dev/help/local-configuration/) (`.tktail`) for the file or its folder - it can
   name your profile (**View As > Set Format for This File / Folder...** lists the profiles).
3. A custom profile that matches.
4. TKTail's content detection (high confidence).
5. File-name hints (low weight).
6. Plain text.

## Record types

A profile can have several record types. They are tried in descending **priority** (equal
priorities in the order listed), and the first that matches wins. At most one type is the
**fallback**, chosen when no other type matches.

A type matches in one of two ways:
- with a **pattern**, in a common field (*Match in* `message`) or in the whole record
  (`$record`);
- with a **condition** over the common fields (`level = ERROR`).

A type can extract its own fields with an **Extract pattern** from a field or the whole record.
Its fields appear only for records of that type. A type's field with the same id as a common
field must be marked **Overrides common**.

Every record gets a `recordType` field, and the Summary shows *Record type* first - so
`recordType = PAYMENT_FAILED` works in search and alert conditions. The Studio's PIPELINE also
says when several types matched one sample (*also matched: ...*), so you can fix priorities.

## Fields

What a field has today:

| Property | Meaning |
|---|---|
| Field id | the name in Fields, the Inspector, search and alert conditions (letters, digits, `_` `.` `-`) |
| Capture group | the named (or numbered) group of the pattern it reads |
| Type | text, integer, decimal, boolean, timestamp, durationMs (milliseconds, shown as *1.50 s (1500)*), enum |
| Semantic role | what the field means (below) |
| Optional | a missing capture is not a problem |
| Condition | the field exists only when this is true, for example `level = ERROR` |
| Overrides common | a record type's field replaces the common field with the same id |
| Value meanings | names for raw values: `200=OK; 404=Not found` - shown beside the value and matched by conditions |

The raw text is always kept. A value that doesn't convert (`abc` for an integer) stays as it
is, with a warning; the record is then shown as *parsed partially*.

Not available (yet): a separate display name, formatting or a presentation priority per field.
Field labels in the Summary come from the id: `elapsed_ms` reads *Elapsed ms*.

**Field states** (RECORD > Fields):
- *extracted*;
- *missing* (optional, not captured);
- *not captured* (required - a warning);
- *condition false* (omitted from the record);
- *conversion failed* (raw value kept).

**Conditions** use the same small language as structured search and alerts: `level = ERROR`,
`status >= 500`, `user.id exists`, `message contains timeout`. They compare fields - there are no
functions, expressions or scripts.

**Source ranges.** Every field keeps its exact place in the record. That is how clicking a field
in the RECORD view, the Inspector or the Studio marks its text in the source, and how the viewer
colours it.

## Semantic roles

| Role | Used for |
|---|---|
| timestamp | the Summary's *Time*, the viewer's timestamp colour |
| severity | the Summary's badge and its colour, the viewer's level colours, conditions such as `severity <= error` |
| message | the Summary's MESSAGE block |
| logger | the Summary's title (*ERROR · Payments*) and *Component* row |
| host, process, thread, user | Summary rows |
| correlation | the title (*ERROR · payment 9921*) - ties records of one operation together |
| duration | the Summary's *Duration* (durationMs values read *1.50 s (1500)*) |
| status, method, url, source, destination, stream, exception | field meanings for search, alerts and the Summary (*Status*, *Exception*) |

Roles also let search and alert conditions name a field by its meaning: `severity = error`
finds the severity field, whatever it is called in your format.

**Severity names.** *Semantics (severity names)* maps your level words to standard severities,
for example `WARN=warning; ERR=error`. The badge colour and `severity <= error` conditions then
understand them.

## The Summary

The RECORD view's Summary for a custom format:
- **Status badge** - a field (usually the level), coloured by severity.
- **Title** - the fields listed in *Title fields*, joined with " · ". Default: the severity and
  the logger's short name.
- **MESSAGE** - the field in *Message* (default: the field with the message role), as its own
  block.
- **Primary fields** - the fields listed, as rows. Default: Time, Duration, Exception, Logger,
  Thread by role.
- **Details** - further fields in a second section.
- *Record type* is always the first row.

Long messages are previewed: the Summary shows the beginning, with **Show Full Message** for
the rest. **Copy**, **Copy Message** and **Export** always use the complete value, never the
preview.

## Samples and Test All

A profile keeps **named samples**: lines or records from your logs, each with an optional file
name (for detection), an **Expected type** and, for multi-line formats, **Expected records** (how
many records the sample must frame into; empty = any).
- **Add Line** / **Add Record** take one from the log you're looking at; **Duplicate** and
  **Remove** edit the list. At most 200 samples of up to 64 Ki characters each.
- **Test All** runs every sample through the draft:
  - a summary such as *10 samples · 10 detected · 9 classified correctly · 1 fallback · 0 parse
    errors*;
  - PASS / FAIL per sample with the reason, for example *expected PAYMENT_FAILED, got
    RECORD* or *expected 2 records, got 5*.
- The toolbar's **Use Current Line / Use Current Record / Use Selection / Paste Sample / Load
  Sample...** replace the sample being previewed. *Load Sample* reads the first 20 lines of a
  file, decoded as UTF-8.

Samples are saved **on this computer** beside the profile (`<profile>.tktsamples.json`), when
you Save. They are never part of an exported definition unless you choose **Export with
Samples** - samples come from your logs and may contain customer data, account numbers or
tokens, so TKTail asks first.

## Import, export and copies

**More** in the Studio's toolbar:
- **Import Definition...**
  - Opens a `*.tktformat.json` file as a draft you can check in the preview first; nothing is
    installed until you Save.
  - A definition from a newer TKTail is refused with a clear message.
  - If its id is already installed, Save asks **Replace** or **Save as Copy**.
  - Samples inside the file are added to the sample list.
- **Export Definition...** writes the current draft (normalized) as it is - the definition only.
- **Export with Samples...** writes the draft plus its samples, after the warning above.
- **Save as Copy** saves the draft under a new id (`<id>-copy`) and name (*(copy)*), without
  the original's detection rules - two profiles claiming the same files would decide by their
  order, not by you.
- **Copy JSON** copies the draft's definition to the clipboard.

From the command line (details in [command-line.md](https://tktail.dev/help/command-line/) and
CLI.md):

```
tktail formats custom list
tktail formats custom validate billing.tktformat.json
tktail formats custom import billing.tktformat.json            # --replace / --copy when the id exists
tktail formats custom export billing billing.tktformat.json   # --force to overwrite
tktail formats custom export-all C:\Backup\Formats
tktail formats custom remove billing --yes
tktail open C:\Logs\billing-2026-10-05.log --format custom:billing
```

Profiles are files in `%LOCALAPPDATA%\TKTail\Formats` (or `data\Formats` beside TKTail.exe in
portable mode). TKTail notices changes when its window becomes active, when the View As >
Custom submenu opens, or with **Reload Custom Formats**. A profile with mistakes is never used:
it is listed as not usable and reported in the **Problems** panel. Safe mode (`--safe-mode`)
loads no profiles.

**From an AI assistant.** An assistant connected to TKTail ([mcp.md](https://tktail.dev/help/mcp/)) can write a profile
for a log - for a delimited log, starting from a draft fitted to it as above - check it and preview it with
TKTail. Why this matters for AI investigations - teach the format once, and every later search, summary, alert,
evidence package and AI session works with its fields - and a step-by-step example:
[AI assistance - Working with your own log formats](https://tktail.dev/help/ai-assistance/#working-with-your-own-log-formats). It gives it to you to import - or, only if you allowed **Allow AI to save custom formats** (Settings > AI
Access, or **Tools > Allow AI to Save Custom Formats**), saves it itself; such a profile is listed here like your
own (Output > Application says when one was saved), and the assistant can only replace the version it read -
never your later edits. The profile file's JSON Schema, for editors and tools that check JSON, is
tktail-format.schema.json.

## Compatibility with alert rules

- **Field schema.** *General* shows the profile's field schema as a short code, a fingerprint
  of its field ids and types (*aa7c9141 · 9 fields*), and says when it *changed since saved*.
  `tktail formats custom list --output json` lists it as `fieldSchema`, with `profileVersion`.
- **Saving a version that removes fields.** If an alert rule tests a field the new version no
  longer has, Save asks first and names the fields and the rules (**Save Anyway** / Cancel).
  After saving, those rules no longer match records of the format.
- **Application log: `component` and `message`.** TKTail's built-in application-log format
  reads the logger name after the level into its own field, `component`. An alert rule that
  tests `message` on an application log may need adjusting. The **Problems** panel says so for
  each such rule.

**Versions.**
- `schemaVersion` is the file format (1). A newer one is refused.
- *Profile version* (General) is your own revision number. Change it when you publish a new
  version; TKTail shows it in `formats custom list` and never changes it itself.

## Built-in formats as a starting point

Only TKTail's **application log** can be cloned (*Clone Built-In: Application Log*). The clone
reads:
- the classic application-log shapes - timestamp, level, an optional dotted component,
  message (the built-in format also learns other field orders from the file; the clone keeps the
  timestamp-first one - edit its envelope pattern for another order);
- records framed like the built-in format: a record starts at a line with a timestamp and a
  level; stack traces, payloads and text after it belong to it;
- an `ERROR` record type with `exception` / `exceptionMessage`.

The clone does not cover everything the built-in format does:
- The built-in **message** is the whole record body (the exception and stack frames included);
  the clone's `message` is the text on the first line - the exception is in `exception`, and the
  whole record is in Source and *Copy Current Record*.
- The bracketed variant `[timestamp] [LEVEL] [Component] [CONTEXT] message` with its `context`
  fields, levels in any letter case, and a level that does not follow the timestamp directly
  (`2026-10-05 10:00:00 [worker-1] ERROR ...`) stay built-in only. In the clone such lines do not
  start a record.

Other built-in formats (FIX, IIS ...) cannot be cloned; they are not expressible as a profile yet.
For delimited files use the **Delimited columns** template (below) - the built-in CSV, TSV and pipe
formats already open such files without a profile. **Qlik Script Trace** cannot be cloned either: its time blocks could be framed with a
record start (a line holding only a time), but counting entries, the fields of a block with one
load and recognizing script errors are built-in only.

## Current limitations

- **Delimited profiles**: a quoted value that contains a line break is not joined into one record
  (every line is a record), as in the built-in CSV formats.
- **Nested payloads.** A JSON object inside a message stays part of the message; reading it as
  its own fields is planned (FORMAT-4).
- **Settings without effect yet.** `highlighting` classes, `nested`, `rotationHints`, `encoding`
  and a record type's *Severity class* are checked and kept, but have no effect yet. Colours
  come from roles and types.
- **Multi-line records** are limited to 2,000 lines / 4 MB in the viewer, even if the profile
  allows more.
- **Not available.**
  - *Test Against Current File* (testing a whole open file);
  - samples on the command line;
  - deleting a profile from the window (use `tktail formats custom remove`).
- **Disabled profiles.** A disabled profile appears in View As > Custom as *(disabled)* but
  cannot be chosen until enabled again.
- **Keyboard.** The Studio's buttons have mnemonic letters, but the Studio has no keyboard
  shortcuts of its own.

## Troubleshooting

| Problem | What to check |
|---|---|
| The profile is not used for a file | Detection: do *Extensions* / *File names* match the file? Does the *Content pattern* match at least *Matching lines* of the first lines? A profile without file names is used only when TKTail's own detection finds nothing; a new profile (template, clone, copy) has no detection rules at all. You can always choose it in View As > Custom or with Use For. |
| A profile takes over logs it was not made for (an IIS log shows `Auto (my profile)`) | Its *Extensions* / *Content pattern* are too broad - the Format tooltip says *Content detector disagrees: ...*. Narrow its *File names*, or remove its detection rules and use **Use For** for the files it is meant for. Profiles made by TKTail before 2026-10-06 from a template or the clone carried `.log` (and `.txt`) with a leading-date pattern: check those. |
| *Not a custom format definition* / the profile is listed as not usable | Open it in the Studio (or run `tktail formats custom validate <file>`): DIAGNOSTICS lists every error with its location. |
| A pattern is invalid | The row under it says what is wrong and at which position (an unmatched `(`, an unknown group name ...). Look-behind is not supported. |
| A stack-trace line is a record of its own | The *Record start* pattern is too broad, or the profile is *One line = one record*. PIPELINE lists every record of the sample with its lines. |
| Several log entries are one record | *Record start* does not match their first lines; PIPELINE says *no line matches the record start* or shows the records it found. |
| The wrong record type is chosen | PIPELINE lists the types that matched; raise the priority of the right one or make its pattern stricter. Give samples an *Expected type* and use Test All. |
| A field is absent | RECORD > Fields shows its state: *condition false*, *missing*, *not captured* (the group did not take part in the match) or *conversion failed*. |
| The Summary is empty | Give a field the *severity* or *message* role, or set the Summary mapping. |
| A field marks the wrong text | The capture group's pattern takes more or less than you expect; SOURCE shows exactly what each group captured. |
| Save is blocked | The draft has errors (DIAGNOSTICS). The saved version stays in use until the draft is valid. |
| *Alert rules test fields this version removes* | Keep the fields (or rename them in the rules) - or Save Anyway when you mean it. |
| A pattern is slow | PIPELINE warns when one record takes more than 2 ms: a pattern may backtrack heavily. Anchor it (`^`) and avoid nested `.*`. |

---

The HTML page: https://tktail.dev/help/custom-formats/
