Skip to content

FileLogHandler

QuantConnect.Logging.FileLogHandler

FileLogHandler(
    filepath: str, use_timestamp_prefix: bool = True
)
FileLogHandler()

Bases: Object, ILogHandler

Provides an implementation of ILogHandler that writes all log messages to a file on disk.

Signature descriptions:

  • Initializes a new instance of the FileLogHandler class to write messages to the specified file path. The file will be opened using FileMode.Append

  • Initializes a new instance of the FileLogHandler class using 'log.txt' for the filepath.

Parameters:

Name Type Description Default
filepath Optional[str]

The file path use to save the log messages

None
use_timestamp_prefix Optional[bool]

True to prefix each line in the log which the UTC timestamp, false otherwise

True

create_message

create_message(text: str, level: str) -> str

Creates the message to be logged

This codeEntityType is protected.

Parameters:

Name Type Description Default
text str

The text to be logged

required
level str

The logging leel

required

debug

debug(text: str) -> None

Write debug message to log

Parameters:

Name Type Description Default
text str

The debug text to log

required

dispose

dispose() -> None

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

error

error(text: str) -> None

Write error message to log

Parameters:

Name Type Description Default
text str

The error text to log

required

trace

trace(text: str) -> None

Write debug message to log

Parameters:

Name Type Description Default
text str

The trace text to log

required