
# The console

The console is the first output of the logging system. On the Dart VM its lines go to standard output; in Flutter and on the web they go to `print`, which reaches the device log (logcat, the system log, `flutter run`).

## Why

During development the console is where you read the logs. Spring Boot's line format puts the same columns in the same place on every line, so a long log stays readable, and colours make the level and the logger stand out. In production, a log collector reads the same lines, without colours.

## Example

```yaml
# lib/resources/application.yml
spring:
  application:
    name: shop
    group: neon
  output:
    ansi:
      enabled: detect      # colours only on a terminal
logging:
  threshold:
    console: info          # the console shows info and above, the file gets everything
  console:
    target: stdout
```

```text
2026-10-23T21:08:01.580Z  INFO 4711 --- [shop] [neon] [           main] neon.checkout                            : paid 12.5 {order=1}
```

## The default line

Without `logging.pattern.console`, the line is Spring Boot's:

| Column | From |
|---|---|
| `2026-10-23T21:08:01.580Z` | `%d` with `logging.pattern.dateformat` (`yyyy-MM-dd'T'HH:mm:ss.SSSXXX`, UTC) |
| `INFO` | `logging.pattern.level` (`%5p`) |
| `4711` | the process id (`${PID}`), empty where there is none (web) |
| `--- [shop] [neon]` | `spring.application.name` and `spring.application.group`, each only when set and `logging.include-application-name` / `-group` is `true` |
| `[           main]` | the isolate name, padded to 15: `main`, or `isolate-2` in an isolate of the web server's [pool](../spring-boot-starter-web/server/isolates.md) |
| `logging.pattern.correlation` | empty by default |
| `neon.checkout` | the logger name, shortened to 39 characters and padded to 40 |
| `paid 12.5 {order=1}` | the message, then the record's fields (`%X`) |
| the error | on the next lines (`logging.exception-conversion-word`, `%wEx`) |

The default pattern, for reference:

```text
%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:-}){magenta} %clr(--- %esb(){APPLICATION_NAME}%esb{APPLICATION_GROUP}[%15.15t] ${LOG_CORRELATION_PATTERN:-}){faint}%clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%X%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}
```

Write your own with `logging.pattern.console`; see [Patterns](patterns.md). An empty `logging.pattern.console=` turns the console off.

## Colours

| `spring.output.ansi.enabled` | Colours |
|---|---|
| `always` (default) | Always, except where the console shows the codes as text (a Flutter app on iOS), where the default is `never` |
| `detect` | Only when standard output is a terminal that understands the codes, or in a Flutter debug or profile build (Spring Boot's default) |
| `never` | Plain text, for logs read by a program: a log collector, Xcode's console, `adb logcat`, output redirected to a file |

Colours come from `%clr(...)` in a pattern. A pattern that colours nothing itself (no `%clr`, no Logback colour) gets Spring Boot's colours anyway: the time faint, the level by level, the logger cyan. Logback's colour words (`%red(...)`, `%highlight(...)`) always write ANSI codes, as in Logback. Files are never coloured.

## Where the lines go

| Setting | Effect |
|---|---|
| `logging.console.target` | `stdout` (default) or `stderr`; `system-out` and `system-err` are Logback's names for the same. Dart VM only |
| `logging.console.enabled=false` | No console output |
| `logging.threshold.console` | The lowest level the console shows (`trace` by default: what the levels allow) |
| `LoggingSystem.instance.console.out` | A function that receives each line; set it in code |

On the Dart VM, standard output is written at once, so a line written right before `exit` is not lost. In Flutter, send the console to `debugPrint` before starting, so long lines are not cut by the device log:

```dart
Future<void> main() async {
  LoggingSystem.instance.console.out = debugPrint;
  await runApplicationAsync(const []);
}
```

Not setting `logging.console.target` leaves an output the application set itself, such as `debugPrint`.

## Levels and thresholds

Levels (`logging.level.*`) decide which records exist at all; a record below its logger's level is never built. Thresholds let one output keep fewer records than the levels allow: a console with only warnings while the file gets everything.

```properties
logging.level.root=debug          # records of debug and above exist
logging.threshold.console=warn    # the console shows warnings and errors
logging.threshold.file=debug      # the file keeps all of them
```

## In Spring (Java)

The same default line, properties and colours as Spring Boot with Logback. Differences: the default of `spring.output.ansi.enabled` is `always`, not `detect`; times are UTC; `%thread` is the isolate name; the fields come after the message as ` {k=v}`.

## See also

- [Patterns](patterns.md)
- [All properties](properties.md)
- [Logging levels](../spring-boot-dart/logging-levels.md)
