spring_boot_starter_logging

spring_boot_starter_logging is the logging backend of Spring for Dart, the Dart counterpart of spring-boot-starter-logging. Add it, and the lines of SpringLog come out in Spring Boot's format, configured by the same logging.* properties a Spring Boot application uses, with Logback's pattern syntax.

No code is needed: the generator finds the starter, and a LoggingSystem is installed behind SpringLog when the application starts. The other starters (web, Feign, WebSocket, scheduling, cache) bring it along.

Why

SpringLog, the logger of spring_core_dart, alone prints plain lines to the console. An application usually wants more:

The starter gives all of this, with Spring Boot's property names, so a Spring Boot configuration works as it is.

Setup

# pubspec.yaml
dependencies:
  spring_boot_starter_logging: ^0.9.0

Run dart run build_runner build again after adding it, so the generated springApplication lists its auto-configuration.

Example

// lib/checkout.dart
import 'package:spring_boot_dart/spring_boot_dart.dart';

import 'spring_gen/app.spring.dart'; // the generated file of the scan holds the log getter

@Service()
@Log(topic: 'neon.checkout') // the logger's name; without topic: <package>.<Class>
class Checkout {
  // The order goes along as a field: searchable, and printed after the message.
  void pay(int order, double amount) =>
      log.info('paid $amount', fields: {'order': order});
}
# lib/resources/application.yml
spring:
  application:
    name: shop
logging:
  level:
    root: info
    neon.checkout: debug
  file:
    name: logs/shop.log

The console line, in Spring Boot's format:

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

The same line goes to logs/shop.log, without colours. Where no generated file is at hand (a library, a script, a top-level function), create the logger yourself: const log = SpringLog('neon.checkout');.

What starts

The auto-configuration (springBootStarterLoggingAutoConfiguration) adds three beans, unless logging.enabled=false:

Bean What it is
loggingSystemInitializer Configures LoggingSystem.instance from the logging.* properties and installs it before any application bean is created; uninstalls it when the context closes
loggingSystem LoggingSystem.instance, to change levels at run time or add appenders
logBuffer The in-memory LogBuffer, for a log screen

The levels (logging.level.*, logging.group.*) are applied by spring_boot_dart itself, with or without this starter; the starter adds the outputs. See Logging levels.

Lines logged during the start, before the system is set up, are replayed into the file, the buffer and added appenders, as Spring Boot's DeferredLogs does. A failed start keeps the system installed until the failure report is logged, so the report reaches the file too.

What is inside

In Spring (Java)

@Slf4j(topic = "neon.checkout")   // Lombok
@Service
class Checkout {
  void pay(int order, double amount) {
    log.info("paid {}", amount);
  }
}
logging.level.neon.checkout=debug
logging.file.name=logs/shop.log
logging.logback.rollingpolicy.max-file-size=10MB

Differences that matter:

See also