Skip to main content

spring_boot_starter_logging 0.1.7 copy "spring_boot_starter_logging: ^0.1.7" to clipboard
spring_boot_starter_logging: ^0.1.7 copied to clipboard

Logging starter for spring_boot_dart: console patterns, log files with rollover, logging.* properties and an in-memory log buffer for in-app log viewers.

example/example.dart

// With spring_boot_dart the starter is picked up automatically: add the
// dependency and log through SpringLog. This example installs the logging
// system by hand, so it runs without code generation.
import 'package:spring_boot_starter_logging/spring_boot_starter_logging.dart';

const log = SpringLog('shop.checkout');

void main() {
  final environment = StandardEnvironment(systemEnvironment: const {})
    ..propertySources.addFirst(
      MapPropertySource('example', {
        'logging.level.shop': 'debug',
        'logging.pattern.console': '%d{HH:mm:ss} %-5p [%logger] %m%X',
      }),
    );
  SpringApplication.applyLoggingLevels(environment);
  final logging = LoggingSystem.instance
    ..configure(environment)
    ..install();

  log.info('order placed', fields: {'order': 42});
  log.debug(() => 'basket checked'); // built only when debug is enabled
  SpringLog.withFields({'request': 'r-1'}, () => log.warning('slow payment'));

  // What an in-app log screen would show: a filtered snapshot.
  final warnings = logging.buffer.query(
    const LogQuery(minLevel: SpringLogLevel.warning),
  );
  print('${warnings.length} warning(s): ${warnings.single.message}');
  logging.uninstall();
}
0
likes
0
points
728
downloads

Publisher

verified publisherfarum-azula.org

Weekly Downloads

Logging starter for spring_boot_dart: console patterns, log files with rollover, logging.* properties and an in-memory log buffer for in-app log viewers.

Repository (GitHub)
View/report issues

Topics

#logging #configuration #spring

License

unknown (license)

Dependencies

spring_boot_dart

More

Packages that depend on spring_boot_starter_logging