FileLogger

FileLogger class

Represents a logger that logs events and errors to a local file.

public class FileLogger : ILogger

Constructors

Name Description
FileLogger(string, double) Initializes a new instance of the FileLogger class.

Properties

Name Description
FilePath { get; } Gets the log file path.
MaxSize { get; } Gets the maximum size of log file in megabytes.

Methods

Name Description
Error(string) Logs an error that occurred in the index.
Trace(string) Logs an event that occurred in the index.

Remarks

Learn more

Examples

The example demonstrates a typical usage of the class.

string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
string query = "Einstein";
string logPath = @"c:\Log.txt";

IndexSettings settings = new IndexSettings();
settings.Logger = new FileLogger(logPath, 4.0); // Specifying the path to the log file and a maximum length of 4 MB

Index index = new Index(indexFolder, settings); // Creating an index in the specified folder

index.Add(documentsFolder); // Indexing documents from the specified folder

SearchResult result = index.Search(query); // Search in index

See Also