Output format
Before output, every Logly message is turned into a line according to LoggerConfiguration.shared.logFormat. That line goes to the console and to the log file. Sinks, in contrast, receive the unformatted individual values.
Placeholders in the Logly output format
The following table lists the placeholders you can use in the Logly logFormat, with examples:
| Placeholder | Replaced with | Example |
|---|---|---|
{timestamp} | Current time in ISO 8601 format, UTC, without fractional seconds | 2026-10-03T14:10:52Z |
{level} | Level name, brought to logLevelWidth | INFO |
{category} | Category name, brought to categoryWidth | Network |
{file} | File name of the caller without path | APIClient.swift |
{line} | Line number of the caller | 42 |
{message} | The message text | Request started |
Rules for placeholders in Logly:
- Each placeholder may appear several times or not at all.
- Unknown placeholders such as
{thread}are left unchanged. - Everything else in the format string is copied literally.
The default Logly format is:
{timestamp} - {level} - {category} - {file}:{line} - {message}
With the default format, a line looks like this:
2026-10-03T14:10:52Z - WARNING - Network - APIClient.swift:42 - Response very slow
Logly format examples
The following example shows different values for logFormat in Logly, each with the result as a comment:
let config = LoggerConfiguration.shared
// Compact
config.logFormat = "{level} {message}"
// INFO Request started
// Category in brackets
config.logFormat = "{timestamp} [{category}] {level} {message}"
// 2026-10-03T14:10:52Z [Network ] INFO Request started
// Source location first
config.logFormat = "{file}:{line} {level} {message}"
// APIClient.swift:42 INFO Request started
// Separator for analysis in spreadsheet tools
config.logFormat = "{timestamp};{level};{category};{file};{line};{message}"
If you analyze log files automatically, pick a separator that does not occur in message text. Logly does not escape anything. If a message contains a line break, it spans several lines in the file.
Column widths in the Logly output format
The Logly settings logLevelWidth and categoryWidth keep columns aligned. Logly brings the text to exactly that length:
- Shorter text is padded with spaces on the right.
- Longer text is truncated.
This is how you set the column widths in Logly:
config.logLevelWidth = 7 // default, fits "WARNING" exactly
config.categoryWidth = 12 // default
config.categoryWidth = 3
// "Network" becomes "Net"
Choose a categoryWidth at least as large as your longest category name. With a logLevelWidth below 7, longer level names are shortened, e.g. WARNING to WAR at width 3.
Colors in the Logly console output
With enableANSIColors = true (the default) Logly puts an ANSI color code in front of every console line and \u{001B}[0m after it to reset. The whole line is colored.
The following table shows the color and ANSI code that Logly uses for each level:
| Level | Color | Code (ansiColorCode) |
|---|---|---|
.debug | Cyan | \u{001B}[0;36m |
.info | Green | \u{001B}[0;32m |
.warning | Yellow | \u{001B}[0;33m |
.error | Red | \u{001B}[0;31m |
.fault | Bright red, bold | \u{001B}[1;31m |
Logly colors only affect the console. The log file never contains color codes.
Whether colors are visible depends on the output window. Terminals such as Terminal.app or iTerm show them. The Xcode debug console shows the control sequences instead. For Xcode, turn colors off:
LoggerConfiguration.shared.enableANSIColors = false
Logly level names and colors in your own code
The Logly type LogLevel exposes both values, for example for a custom sink:
let level = LogLevel.warning
print(level.description) // "WARNING"
print(level.ansiColorCode) // "\u{001B}[0;33m"
print(level.rawValue) // 3