Serilog.Sinks.File
Extends with methods to add file sinks.
Write log events to the specified file.
Logger sink configuration.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
Supplies culture-specific formatting information, or null.
A message template describing the format used to write to the sink.
the default is "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}".
The approximate maximum size, in bytes, to which a log file will be allowed to grow.
For unrestricted growth, pass null. The default is 1 GB. To avoid writing partial events, the last event within the limit
will be written in full even if it exceeds the limit.
Indicates if flushing to the output file can be buffered or not. The default
is false.
Allow the log file to be shared by multiple processes. The default is false.
If provided, a full disk flush will be performed periodically at the specified interval.
Configuration object allowing method chaining.
The file will be written using the UTF-8 character set.
Write log events to the specified file.
Logger sink configuration.
A formatter, such as , to convert the log events into
text for the file. If control of regular text formatting is required, use the other
overload of
and specify the outputTemplate parameter instead.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
The approximate maximum size, in bytes, to which a log file will be allowed to grow.
For unrestricted growth, pass null. The default is 1 GB. To avoid writing partial events, the last event within the limit
will be written in full even if it exceeds the limit.
Indicates if flushing to the output file can be buffered or not. The default
is false.
Allow the log file to be shared by multiple processes. The default is false.
If provided, a full disk flush will be performed periodically at the specified interval.
Configuration object allowing method chaining.
The file will be written using the UTF-8 character set.
Write log events to the specified file.
Logger sink configuration.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
Supplies culture-specific formatting information, or null.
A message template describing the format used to write to the sink.
the default is "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}".
The approximate maximum size, in bytes, to which a log file will be allowed to grow.
For unrestricted growth, pass null. The default is 1 GB. To avoid writing partial events, the last event within the limit
will be written in full even if it exceeds the limit.
Indicates if flushing to the output file can be buffered or not. The default
is false.
Allow the log file to be shared by multiple processes. The default is false.
If provided, a full disk flush will be performed periodically at the specified interval.
The interval at which logging will roll over to a new file.
If true
, a new file will be created when the file size limit is reached. Filenames
will have a number appended in the format _NNN
, with the first filename given no number.
The maximum number of log files that will be retained,
including the current log file. For unlimited retention, pass null. The default is 31.
Character encoding used to write the text file. The default is UTF-8 without BOM.
Configuration object allowing method chaining.
Write log events to the specified file.
Logger sink configuration.
A formatter, such as , to convert the log events into
text for the file. If control of regular text formatting is required, use the other
overload of
and specify the outputTemplate parameter instead.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
The approximate maximum size, in bytes, to which a log file will be allowed to grow.
For unrestricted growth, pass null. The default is 1 GB. To avoid writing partial events, the last event within the limit
will be written in full even if it exceeds the limit.
Indicates if flushing to the output file can be buffered or not. The default
is false.
Allow the log file to be shared by multiple processes. The default is false.
If provided, a full disk flush will be performed periodically at the specified interval.
The interval at which logging will roll over to a new file.
If true
, a new file will be created when the file size limit is reached. Filenames
will have a number appended in the format _NNN
, with the first filename given no number.
The maximum number of log files that will be retained,
including the current log file. For unlimited retention, pass null. The default is 31.
Character encoding used to write the text file. The default is UTF-8 without BOM.
Configuration object allowing method chaining.
Write log events to the specified file.
Logger sink configuration.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
Supplies culture-specific formatting information, or null.
A message template describing the format used to write to the sink.
the default is "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}".
The approximate maximum size, in bytes, to which a log file will be allowed to grow.
For unrestricted growth, pass null. The default is 1 GB. To avoid writing partial events, the last event within the limit
will be written in full even if it exceeds the limit.
Indicates if flushing to the output file can be buffered or not. The default
is false.
Allow the log file to be shared by multiple processes. The default is false.
If provided, a full disk flush will be performed periodically at the specified interval.
The interval at which logging will roll over to a new file.
If true
, a new file will be created when the file size limit is reached. Filenames
will have a number appended in the format _NNN
, with the first filename given no number.
The maximum number of log files that will be retained,
including the current log file. For unlimited retention, pass null. The default is 31.
Character encoding used to write the text file. The default is UTF-8 without BOM.
Optionally enables hooking into log file lifecycle events.
Configuration object allowing method chaining.
Write log events to the specified file.
Logger sink configuration.
A formatter, such as , to convert the log events into
text for the file. If control of regular text formatting is required, use the other
overload of
and specify the outputTemplate parameter instead.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
The approximate maximum size, in bytes, to which a log file will be allowed to grow.
For unrestricted growth, pass null. The default is 1 GB. To avoid writing partial events, the last event within the limit
will be written in full even if it exceeds the limit.
Indicates if flushing to the output file can be buffered or not. The default
is false.
Allow the log file to be shared by multiple processes. The default is false.
If provided, a full disk flush will be performed periodically at the specified interval.
The interval at which logging will roll over to a new file.
If true
, a new file will be created when the file size limit is reached. Filenames
will have a number appended in the format _NNN
, with the first filename given no number.
The maximum number of log files that will be retained,
including the current log file. For unlimited retention, pass null. The default is 31.
Character encoding used to write the text file. The default is UTF-8 without BOM.
Optionally enables hooking into log file lifecycle events.
Configuration object allowing method chaining.
Write log events to the specified file.
Logger sink configuration.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
Supplies culture-specific formatting information, or null.
A message template describing the format used to write to the sink.
the default is "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}".
Configuration object allowing method chaining.
The file will be written using the UTF-8 character set.
Write log events to the specified file.
Logger sink configuration.
A formatter, such as , to convert the log events into
text for the file. If control of regular text formatting is required, use the other
overload of
and specify the outputTemplate parameter instead.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
Configuration object allowing method chaining.
The file will be written using the UTF-8 character set.
Write audit log events to the specified file.
Logger sink configuration.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
Supplies culture-specific formatting information, or null.
A message template describing the format used to write to the sink.
the default is "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}".
Character encoding used to write the text file. The default is UTF-8 without BOM.
Optionally enables hooking into log file lifecycle events.
Configuration object allowing method chaining.
Write audit log events to the specified file.
Logger sink configuration.
A formatter, such as , to convert the log events into
text for the file. If control of regular text formatting is required, use the other
overload of
and specify the outputTemplate parameter instead.
Path to the file.
The minimum level for
events passed through the sink. Ignored when is specified.
A switch allowing the pass-through minimum level
to be changed at runtime.
Character encoding used to write the text file. The default is UTF-8 without BOM.
Optionally enables hooking into log file lifecycle events.
Configuration object allowing method chaining.
Specifies the frequency at which the log file should roll.
The log file will never roll; no time period information will be appended to the log file name.
Roll every year. Filenames will have a four-digit year appended in the pattern yyyy
.
Roll every calendar month. Filenames will have yyyyMM
appended.
Roll every day. Filenames will have yyyyMMdd
appended.
Roll every hour. Filenames will have yyyyMMddHH
appended.
Roll every minute. Filenames will have yyyyMMddHHmm
appended.
Enables hooking into log file lifecycle events.
Hooks run synchronously and therefore may affect responsiveness of the application if long operations are performed.
Initialize or wrap the opened on the log file. This can be used to write
file headers, or wrap the stream in another that adds buffering, compression, encryption, etc. The underlying
file may or may not be empty when this method is called.
A value must be returned from overrides of this method. Serilog will flush and/or dispose the returned value, but will not
dispose the stream initially passed in unless it is itself returned.
The underlying opened on the log file.
The encoding to use when reading/writing to the stream.
The Serilog should use when writing events to the log file.
Called before an obsolete (rolling) log file is deleted.
This can be used to copy old logs to an archive location or send to a backup server.
The full path to the file being deleted.
Write log events to a disk file.
Construct a .
Path to the file.
Formatter used to convert log events to text.
The approximate maximum size, in bytes, to which a log file will be allowed to grow.
For unrestricted growth, pass null. The default is 1 GB. To avoid writing partial events, the last event within the limit
will be written in full even if it exceeds the limit.
Character encoding used to write the text file. The default is UTF-8 without BOM.
Indicates if flushing to the output file can be buffered or not. The default
is false.
Configuration object allowing method chaining.
This constructor preserves compatibility with early versions of the public API. New code should not depend on this type.
Emit the provided log event to the sink.
The log event to write.
Exists only for the convenience of , which
switches implementations based on sharing. Would refactor, but preserving
backwards compatibility.
Supported by (file-based) sinks that can be explicitly flushed.
Flush buffered contents to disk.
An instance of this sink may be substituted when an instance of the
is unable to be constructed.
A sink wrapper that periodically flushes the wrapped sink to disk.
Construct a that wraps
and flushes it at the specified .
The sink to wrap.
The interval at which to flush the underlying sink.
Write log events to a disk file.
Construct a .
Path to the file.
Formatter used to convert log events to text.
The approximate maximum size, in bytes, to which a log file will be allowed to grow.
For unrestricted growth, pass null. The default is 1 GB. To avoid writing partial events, the last event within the limit
will be written in full even if it exceeds the limit.
Character encoding used to write the text file. The default is UTF-8 without BOM.
Configuration object allowing method chaining.
The file will be written using the UTF-8 character set.
Emit the provided log event to the sink.
The log event to write.