/// <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
            _configuration = configuration;

            // Set the path
            _filePath = path;
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="categoryName">The category for this file logger</param>
        /// <param name="filePath">The file path to log to</param>
        /// <param name="configuration">The configuration to use</param>
        public FileLogger(string categoryName, string filePath, FileLoggerConfiguration configuration)
        {
            // Get the absolute path
            filePath = Path.GetFullPath(filePath);

            // Set members
            _categoryName  = categoryName;
            _filePath      = filePath;
            _configuration = configuration;
        }
Example #3
0
        /// <summary>
        /// Add 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 file logger configuration</param>
        /// <returns></returns>
        public static ILoggingBuilder AddFile(this ILoggingBuilder builder, string path, FileLoggerConfiguration configuration = null)
        {
            if (configuration == null)
            {
                configuration = new FileLoggerConfiguration();
            }

            // Add file log provider to builder
            builder.AddProvider(new FileLoggerProvider(path, configuration));

            return(builder);
        }