FileLog
A log which outputs events to a file.
Set Up
Include Logging.File
library in project:
An ILog
is created using the FileLog
:
Create logs:
Use Flush
or FlushAsync
to ensure that logged events are written to file:
Configure the log. For example, change the file name. Let it contain the current time:
Choose enabled log levels. Only messages of these levels will be written to the file:
Change encoding:
See the section about Advanced Usage for samples of settings usage.
Configurations
The above is an example of how to configure a log file from code. However, this is not the only way to build this process.
There are two ways to configure Vostok's FileLog:
create settings file;
set settings provider.
Sample configuration file :
Settings
These parameters are adjusted in FileLogSettings
:
Parameters | Description |
Path to the log file. | |
Used to render log messages. | |
If specified, this IFormatProvider will be used when formatting log property values. | |
Specifies the way to treat an existing log file: append (default) or rewrite. | |
An optional rolling strategy (disabled by default). | |
Output text encoding (UTF-8 by default). | |
Output buffer size, in bytes (64K by default). | |
A whitelist of enabled LogLevels. | |
Capacity of the internal log events queue. | |
Specifies how many log events are processed in one iteration for each file. | |
Cooldown for enforcing file-related settings (name, rolling strategy, buffer size, etc.). |
Last updated