addLogging method

ServiceCollection addLogging([
  1. ConfigureLoggingBuilder? configure
])

Adds logging services to the specified ServiceCollection.

Implementation

ServiceCollection addLogging([ConfigureLoggingBuilder? configure]) {
  tryAdd(ServiceDescriptor.singleton<LoggerFactory>(
    (services) => LoggerFactory(
      (services.getServices<LoggerProvider>() as List)
          .map((item) => item as LoggerProvider)
          .toList(),
      services.getService<OptionsMonitor<LoggerFilterOptions>>(),
    ),
  ));

  tryAddIterable(
    ServiceDescriptor.singletonInstance<
        ConfigureOptions<LoggerFilterOptions>>(
      DefaultLoggerLevelConfigureOptions(LogLevel.information),
    ),
  );

  if (configure != null) {
    configure(LoggingBuilder._(this));
  }

  return this;
}