com.groupdocs.search.common

Class FileLogger

  • All Implemented Interfaces:
    ILogger


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

      • FileLogger

        public FileLogger(String filePath,
                  double maxSize)

        Initializes a new instance of the FileLogger class.

        Parameters:
        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
        Parameters:
        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
        Parameters:
        message - The event message.
      • getFilePath

        public final String getFilePath()

        Gets the log file path.

        Returns:
        The log file path.
      • getMaxSize

        public final double getMaxSize()

        Gets the maximum size of log file in megabytes.

        Returns:
        The maximum size of log file in megabytes.