/// <summary> /// Default constructor /// </summary> /// <param name="path">The path to log to</param> /// <param name="configuration">The configuration to use</param> public FileLoggerProvider(string path, FileLoggerConfiguration configuration) { // Set the configuration mConfiguration = configuration; // Set the path mFilePath = path; }
/// <summary> /// Default constructor /// </summary> /// <param name="categoryName">The category for this logger</param> /// <param name="filePath">The file path to write to</param> /// <param name="configuration">The configuration to use</param> public FileLogger(string categoryName, string filePath, FileLoggerConfiguration configuration) { // Get absolute path filePath = Path.GetFullPath(filePath); // Set members mCategoryName = categoryName; mFilePath = filePath; mDirectory = Path.GetDirectoryName(filePath); mConfiguration = configuration; }
/// <summary> /// Adds a new file logger to the specific path /// </summary> /// <param name="builder">The log builder to add to</param> /// <param name="path">The path where to write to</param> /// <param name="configuration">The configuration</param> /// <returns></returns> public static ILoggingBuilder AddFile(this ILoggingBuilder builder, string path, FileLoggerConfiguration configuration = null) { // Create default configuration if not provided if (configuration == null) { configuration = new FileLoggerConfiguration(); } // Add file log provider to builder builder.AddProvider(new FileLoggerProvider(path, configuration)); // Return the builder return(builder); }