FileLogger class

FileLogger class

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

Learn more

The FileLogger type exposes the following members:

Constructors

Constructor Description
init Initializes a new FileLogger instance.

Methods

Method Description
error Logs an error that occurred in the index.
trace Logs an event that occurred in the index.

Properties

Property Description
file_path The log file path.
max_size The maximum size of the log file in megabytes.

Example

import os
from groupdocs.search import Index, IndexSettings
from groupdocs.search.common import FileLogger

log_path = "./output/log.txt"
os.makedirs("./output", exist_ok=True)

settings = IndexSettings()
settings.logger = FileLogger(log_path, 4.0)  # path to log file and max size 4 MB

index = Index("./index", settings)
index.add("./documents")
result = index.search("Einstein")

with open(log_path, encoding="utf-8") as f:
    print(f.read())

See Also