FileLoggerBuilderExtensions Class
Provides extension methods for ILoggingBuilder to add file logging support.
public static class FileLoggerBuilderExtensionsExample
var builder = Host.CreateApplicationBuilder(args);
builder.Logging.AddFile(options =>
{
options.Directory = "logs";
options.RollInterval = RollInterval.Daily;
options.MaxRetainedFiles = 7;
});Methods
| Name | Description |
|---|---|
| AddFile(ILoggingBuilder) | Adds a file logger provider to the logging builder. The options are read from the Logging:File configuration section. |
| AddFile(ILoggingBuilder, Action<FileLoggerOptions>) | Adds a file logger provider configured by the specified delegate. |
| AddFile(ILoggingBuilder, string) | Adds a file logger provider that writes to the specified directory. |
| AddFile(ILoggingBuilder, string, Action<FileLoggerOptions>) | Adds a file logger provider that writes to the specified directory and is configured by the specified delegate. |
AddFile overloads
AddFile(ILoggingBuilder)
FileLoggerBuilderExtensions.csAdds a file logger provider to the logging builder. The options are read from the Logging:File configuration section.
public static ILoggingBuilder AddFile(this ILoggingBuilder builder)Parameters
builderILoggingBuilder- The
ILoggingBuilderto add the provider to.
Returns
ILoggingBuilder The ILoggingBuilder so that additional calls can be chained.
AddFile(ILoggingBuilder, Action<FileLoggerOptions>)
FileLoggerBuilderExtensions.csAdds a file logger provider configured by the specified delegate.
public static ILoggingBuilder AddFile(this ILoggingBuilder builder, Action<FileLoggerOptions> configure)Parameters
builderILoggingBuilder- The
ILoggingBuilderto add the provider to. configureAction<FileLoggerOptions>- A delegate to configure the options of the provider.
Returns
ILoggingBuilder The ILoggingBuilder so that additional calls can be chained.
AddFile(ILoggingBuilder, string)
FileLoggerBuilderExtensions.csAdds a file logger provider that writes to the specified directory.
public static ILoggingBuilder AddFile(this ILoggingBuilder builder, string logsDirectory)Parameters
builderILoggingBuilder- The
ILoggingBuilderto add the provider to. logsDirectorystring- The directory where log files will be written.
Returns
ILoggingBuilder The ILoggingBuilder so that additional calls can be chained.
AddFile(ILoggingBuilder, string, Action<FileLoggerOptions>)
FileLoggerBuilderExtensions.csAdds a file logger provider that writes to the specified directory and is configured by the specified delegate.
public static ILoggingBuilder AddFile(this ILoggingBuilder builder, string logsDirectory, Action<FileLoggerOptions> configure)Parameters
builderILoggingBuilder- The
ILoggingBuilderto add the provider to. logsDirectorystring- The directory where log files will be written.
configureAction<FileLoggerOptions>- A delegate to configure the options of the provider.
Returns
ILoggingBuilder The ILoggingBuilder so that additional calls can be chained.