FileLogger
Leave feedback
On this page
Inheritance: java.lang.Object
All Implemented Interfaces: com.groupdocs.search.common.ILogger
public class FileLogger 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 | Description |
|---|---|
| FileLogger(String filePath, double maxSize) | Initializes a new instance of the FileLogger class. |
| Method | Description |
|---|---|
| error(String message) | Logs an error that occurred in the index. |
| trace(String message) | Logs an event that occurred in the index. |
| getFilePath() | Gets the log file path. |
| getMaxSize() | Gets the maximum size of log file in megabytes. |
public FileLogger(String filePath, double maxSize)
Initializes a new instance of the FileLogger class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| filePath | java.lang.String | The log file path. |
| maxSize | double | The maximum size of the log file in megabytes. The value must be in the range from 0.1 to 1000. |
public final void error(String message)
Logs an error that occurred in the index.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| message | java.lang.String | The error message. |
public final void trace(String message)
Logs an event that occurred in the index.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| message | java.lang.String | The event message. |
public final String getFilePath()
Gets the log file path.
Returns: java.lang.String - The log file path.
public final double getMaxSize()
Gets the maximum size of log file in megabytes.
Returns: double - The maximum size of log file in megabytes.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.