Regex patterns
Regex patterns teach Logswarm how to split a log line into named columns. Create them under Settings → Regex, then assign a pattern to each directory location (or preset) you care about.
Required pieces
- Extraction regex with at least one capturing group
(...) - A name for each group (becomes a column / Complex field)
- Exactly one group marked Timestamp
- Timestamp date format using Java-style tokens (e.g.
yyyy-MM-dd HH:mm:ss,SSS)
Optional: Boundary regex for multi-line records.
Example 1 — Java / Log4j-style application log
Sample line:
2026-07-06 12:21:37,393 INFO pl.npesystem.service.consumer [JMSConsumer-339] Sending message to queue, message {"id":1234567890}
Extraction regex:
^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\s+([A-Z]+)\s+([\w\.]+)\s+(\[.*?\])\s+(.*)$
| Group | Suggested name | Timestamp? |
|---|---|---|
| 1 | timestamp | Yes |
| 2 | level | |
| 3 | logger | |
| 4 | thread | |
| 5 | message |
Timestamp date format:
yyyy-MM-dd HH:mm:ss,SSS
After assignment, column filters can target level=INFO, thread containing 339, etc.
Complex mode example
With that pattern assigned:
- Select the directory/preset in Search in.
- Switch to Complex → Edit groups.
- Set
level=ERRORandlogger=SingleConsumer(substring). - Apply, then Search.
Within one group, OR with ||, e.g. level = ERROR || WARN.
Example 2 — Nginx-style access log (ISO-ish time)
Sample line:
2026-07-06T14:21:06+02:00 10.0.0.12 "GET /health HTTP/1.1" 200 15
Extraction regex:
^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+\-]\d{2}:\d{2})\s+(\S+)\s+"([A-Z]+)\s+([^"]+)"\s+(\d{3})\s+(\d+)$
| Group | Suggested name | Timestamp? |
|---|---|---|
| 1 | timestamp | Yes |
| 2 | client_ip | |
| 3 | method | |
| 4 | request | |
| 5 | status | |
| 6 | bytes |
Timestamp date format (adjust if your offset/format differs):
yyyy-MM-dd'T'HH:mm:ssXXX
If parsing fails for your exact timestamp variant, tighten the capturing group and format tokens until a sample value parses — unparseable timestamps still appear but sort last.
Assign the pattern
- Save the pattern under Regex.
- Open Directories → edit a location → set Regex pattern to your pattern (not None (legacy parser)).
- Or set a pattern on a Preset when that fits your workflow.
- Run a search and confirm columns appear; then use column filters.
Tips
- Prefer named, stable group names (
level, notgroup_2) — they show up in Complex mode and filters. - Keep the timestamp group’s text format aligned with Timestamp date format.
- Use non-capturing groups
(?:...)for parts you do not want as columns. - Invalid regex blocks save; the form requires at least one capturing group.