FileLogListener

Ecng.Logging

The logger recording the data to a text file.

继承自: LogListener

构造函数

FileLogListener
public FileLogListener(IFileSystem fileSystem)
fileLogListener = FileLogListener(fileSystem)

To create FileLogListener with custom file system.

fileSystem
The file system to use for file operations.
FileLogListener
public FileLogListener(string fileName)
fileLogListener = FileLogListener(fileName)

To create FileLogListener. All messages from the Log will be recorded to the file .

fileName
The name of a text file to which messages from the event Log will be recorded.
FileLogListener
public FileLogListener()
fileLogListener = FileLogListener()

To create FileLogListener. For each ILogSource a separate file with a name equal to Name will be created.

FileLogListener
public FileLogListener(IFileSystem fileSystem, string fileName)
fileLogListener = FileLogListener(fileSystem, fileName)

To create FileLogListener with custom file system. All messages from the Log will be recorded to the file .

fileSystem
The file system to use for file operations.
fileName
The name of a text file to which messages from the event Log will be recorded.

属性

Append
public bool Append { get; set; }
value = fileLogListener.Append
fileLogListener.Append = value

Whether to add the data to a file, if it already exists. The default is off.

DirectoryDateFormat
public string DirectoryDateFormat { get; set; }
value = fileLogListener.DirectoryDateFormat
fileLogListener.DirectoryDateFormat = value

The directory name format that represents a date. By default is 'yyyy_MM_dd'.

Encoding
public Encoding Encoding { get; set; }
value = fileLogListener.Encoding
fileLogListener.Encoding = value

File encoding. The default is UTF-8 encoding.

Extension
public string Extension { get; set; }
value = fileLogListener.Extension
fileLogListener.Extension = value

Extension of log files. The default value is '.txt'.

FileName
public string FileName { get; set; }
value = fileLogListener.FileName
fileLogListener.FileName = value

The name of a text file (without filename extension) to which messages from the event Log will be recorded.

FileSystem
public IFileSystem FileSystem { get; }
value = fileLogListener.FileSystem

The file system used for file operations.

HistoryAfter
public TimeSpan HistoryAfter { get; set; }
value = fileLogListener.HistoryAfter
fileLogListener.HistoryAfter = value

Offset from present day indicates are logs are out of date.

HistoryCompressionLevel
public CompressionLevel HistoryCompressionLevel { get; set; }
value = fileLogListener.HistoryCompressionLevel
fileLogListener.HistoryCompressionLevel = value

Uses in case of Compression. Default is Optimal.

HistoryMove
public string HistoryMove { get; set; }
value = fileLogListener.HistoryMove
fileLogListener.HistoryMove = value

Uses in case of Move. Default is .

HistoryPolicy
public FileLogHistoryPolicies HistoryPolicy { get; set; }
value = fileLogListener.HistoryPolicy
fileLogListener.HistoryPolicy = value

FileLogHistoryPolicies. By default is None.

LogDirectory
public string LogDirectory { get; set; }
value = fileLogListener.LogDirectory
fileLogListener.LogDirectory = value

The directory where the log file will be created. By default, it is the directory where the executable file is located.

MaxCount
public int MaxCount { get; set; }
value = fileLogListener.MaxCount
fileLogListener.MaxCount = value

The maximum number of rolling files. The default is 0, which means that the files will be rolled without limitation.

MaxLength
public long MaxLength { get; set; }
value = fileLogListener.MaxLength
fileLogListener.MaxLength = value

The maximum length of the log file. The default is 0, which means that the file will have unlimited size.

SeparateByDates
public SeparateByDateModes SeparateByDates { get; set; }
value = fileLogListener.SeparateByDates
fileLogListener.SeparateByDates = value

The mode of log files splitting by date. The default mode is None.

WriteChildDataToRootFile
public bool WriteChildDataToRootFile { get; set; }
value = fileLogListener.WriteChildDataToRootFile
fileLogListener.WriteChildDataToRootFile = value

To record the subsidiary sources data to the parent file. The default mode is enabled.

WriteSourceId
public bool WriteSourceId { get; set; }
value = fileLogListener.WriteSourceId
fileLogListener.WriteSourceId = value

To output the source identifier Id to a file. The default is off.

方法

DisposeManaged
protected override void DisposeManaged()
fileLogListener.DisposeManaged()

Release resources.

LoadAsync
public override Task LoadAsync(SettingsStorage storage, CancellationToken cancellationToken)
result = fileLogListener.LoadAsync(storage, cancellationToken)

Load settings.

storage
Settings storage.
cancellationToken
CancellationToken

返回值: Task

OnCreateWriter
private StreamWriterEx OnCreateWriter(string fileName)
result = fileLogListener.OnCreateWriter(fileName)

To create a text writer.

fileName
The name of the text file to which messages from the event Log will be recorded.

返回值: A text writer.

OnWriteMessagesAsync
protected override ValueTask OnWriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken cancellationToken)
result = fileLogListener.OnWriteMessagesAsync(messages, cancellationToken)

To record messages asynchronously.

messages
Debug messages.
cancellationToken
Cancellation token.

返回值: A task that represents the asynchronous write operation.

SaveAsync
public override Task SaveAsync(SettingsStorage storage, CancellationToken cancellationToken)
result = fileLogListener.SaveAsync(storage, cancellationToken)

Save settings.

storage
Settings storage.
cancellationToken
CancellationToken

返回值: Task