Class FileLogger

  • All Implemented Interfaces:

    public class FileLogger
    extends Object
    implements ILogger
    Represents a logger that logs events and errors to a local file.

    Learn more

    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.setLogger(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 =; // Search in index
    • Constructor Detail

      • FileLogger

        public FileLogger(String filePath,
                          double maxSize)
        Initializes a new instance of the FileLogger class.
        filePath - The log file path.
        maxSize - The maximum size of the log file in megabytes. The value must be in the range from 0.1 to 1000.
    • Method Detail

      • error

        public final void error(String message)
        Logs an error that occurred in the index.
        Specified by:
        error in interface ILogger
        message - The error message.
      • trace

        public final void trace(String message)
        Logs an event that occurred in the index.
        Specified by:
        trace in interface ILogger
        message - The event message.
      • getFilePath

        public final String getFilePath()
        Gets the log file path.
        The log file path.
      • getMaxSize

        public final double getMaxSize()
        Gets the maximum size of log file in megabytes.
        The maximum size of log file in megabytes.