메소드 | 설명 | |
---|---|---|
CleanupInitializedFiles ( ) : void |
Removes records of initialized files that have not been accessed in the last two days. Files are marked 'initialized' for the purpose of writing footers when the logging finishes. |
|
CleanupInitializedFiles ( System.DateTime cleanupThreshold ) : void |
Removes records of initialized files that have not been accessed after the specified date. Files are marked 'initialized' for the purpose of writing footers when the logging finishes. |
|
FileTarget ( ) : System |
Initializes a new instance of the FileTarget class. The default value of the layout is: |
|
FileTarget ( string name ) : System |
Initializes a new instance of the FileTarget class. The default value of the layout is: |
메소드 | 설명 | |
---|---|---|
CloseTarget ( ) : void |
Closes the file(s) opened for writing.
|
|
FlushAsync ( AsyncContinuation asyncContinuation ) : void |
Flushes all pending file operations. The timeout parameter is ignored, because file APIs don't provide the needed functionality. |
|
GetBytesToWrite ( LogEventInfo logEvent ) : byte[] |
Gets the bytes to be written to the file.
|
|
GetFormattedMessage ( LogEventInfo logEvent ) : string |
Formats the log event for write.
|
|
InitializeTarget ( ) : void |
Initializes file logging by creating data structures that enable efficient multi-file logging.
|
|
TransformBytes ( byte value ) : byte[] |
Modifies the specified byte array before it gets sent to a file.
|
|
Write ( NLog.Common.AsyncLogEventInfo logEvents ) : void |
Writes the specified array of logging events to a file specified in the FileName parameter. This function makes use of the fact that the events are batched by sorting the requests by filename. This optimizes the number of open/close calls and can help improve performance. |
|
Write ( LogEventInfo logEvent ) : void |
Writes the specified logging event to a file specified in the FileName parameter.
|
메소드 | 설명 | |
---|---|---|
ArchiveByDate ( string fileName, string pattern, LogEventInfo logEvent ) : void |
Archives the fileName using a date style numbering. Archives will be stamped with the prior period (Year, Month, Day, Hour, Minute) datetime. When the number of archive files exceed
|
|
ArchiveByDateAndSequence ( string fileName, string pattern, LogEventInfo logEvent ) : void |
Archives the fileName using a date and sequence style numbering. Archives will be stamped with the prior period (Year, Month, Day) datetime. The most recent archive has the highest number (in combination with the date). When the number of archive files exceed P:MaxArchiveFiles the obsolete archives are deleted.
|
|
ArchiveBySequence ( string fileName, string pattern ) : void |
Archives the fileName using a sequence style numbering. The most recent archive has the highest number. When the number of archive files exceed P:MaxArchiveFiles the obsolete archives are deleted.
|
|
ArchiveFile ( string fileName, string archiveFileName ) : void |
Archives fileName to archiveFileName.
|
|
AutoClosingTimerCallback ( object state ) : void | ||
ContainsFileNamePattern ( string fileName ) : bool |
Determines if the file name as String contains a numeric pattern i.e. {#} in it. Example: trace{#}.log Contains the numeric pattern. trace{###}.log Contains the numeric pattern. trace{#X#}.log Contains the numeric pattern (See remarks). trace.log Does not contain the pattern. Occasionally, this method can identify the existence of the {#} pattern incorrectly. |
|
CreateFileNameLayout ( |
||
DeleteAndWaitForFileDelete ( string fileName ) : void | ||
DeleteOldArchiveFile ( string fileName ) : bool | ||
DeleteOldDateArchives ( string pattern ) : void |
Deletes archive files in reverse chronological order until only the MaxArchiveFiles number of archive files remain.
|
|
DoAutoArchive ( string fileName, LogEventInfo eventInfo ) : void |
Invokes the archiving process after determining when and which type of archiving is required.
|
|
EnsureArchiveCount ( List |
Deletes files among a given list, and stops as soon as the remaining files are fewer than the Items are deleted in the same order as in oldArchiveFileNames. No file is deleted if |
|
FinalizeFile ( string fileName, bool isArchiving = false ) : void |
Writes the file footer and finalizes the file in FileTarget instance internal structures.
|
|
FindDateAndSequenceArchives ( string dirName, string logFileName, string fileNameMask, int minSequenceLength, string dateFormat, FileNameTemplate fileTemplate ) : IEnumerable |
Searches a given directory for archives that comply with the current archive pattern.
|
|
FlushCurrentFileWrites ( string currentFileName, LogEventInfo firstLogEvent, |
||
GetArchiveDate ( string fileName, LogEventInfo logEvent ) : System.DateTime | ||
GetArchiveDateFormatString ( string defaultFormat ) : string |
Gets the correct formatting
|
|
GetArchiveFileName ( string fileName, LogEventInfo ev, int upcomingWriteSize ) : string |
Indicates if the automatic archiving process should be executed.
|
|
GetArchiveFileNameBasedOnFileSize ( string fileName, int upcomingWriteSize ) : string |
Gets the file name for archiving, or null if archiving should not occur based on file size.
|
|
GetArchiveFileNameBasedOnTime ( string fileName, LogEventInfo logEvent ) : string |
Returns the file name for archiving, or null if archiving should not occur based on date/time.
|
|
GetArchiveFileNamePattern ( string fileName, LogEventInfo eventInfo ) : string |
Gets the pattern that archive files will match
|
|
GetFileAppenderFactory ( ) : IFileAppenderFactory |
Returns the suitable appender factory ( IFileAppenderFactory) to be used to generate the file appenders associated with the FileTarget instance. The type of the file appender factory returned depends on the values of various FileTarget properties.
|
|
GetFiles ( |
Gets the collection of files in the specified directory which they match the fileNameMask.
|
|
GetFooterBytes ( ) : byte[] |
The sequence of
|
|
GetFullFileName ( LogEventInfo logEvent ) : string |
Get full filename (=absolute) and cleaned if needed.
|
|
GetHeaderBytes ( ) : byte[] |
The sequence of
|
|
GetLayoutBytes ( |
The sequence of Usually it is used to render the header and hooter of the files. |
|
GetPotentialFileForArchiving ( string fileName ) : string |
Returns the correct filename to archive
|
|
InitializeFile ( string fileName, LogEventInfo logEvent, bool justData ) : bool |
Initialise a file to be used by the FileTarget instance. Based on the number of initialised files and the values of various instance properties clean up and/or archiving processes can be invoked.
|
|
IsArchivingEnabled ( ) : bool | ||
PreviousLogOverlappedPeriod ( LogEventInfo logEvent, System.DateTime lastWrite ) : bool | ||
ProcessLogEvent ( LogEventInfo logEvent, string fileName, byte bytesToWrite ) : void | ||
ProcessOnStartup ( string fileName, LogEventInfo logEvent ) : void |
Invokes the archiving and clean up of older archive file based on the values of
|
|
RefreshArchiveFilePatternToWatch ( ) : void |
Refresh the ArchiveFilePatternToWatch option of the FileAppenderCache. The log file must be watched for archiving when multiple processes are writing to the same open file.
|
|
RefreshFileArchive ( ) : void | ||
ReplaceFileContent ( string fileName, byte bytes, bool firstAttempt ) : void |
Creates the file specified in fileName and writes the file content in each entirety i.e. Header, Content and Footer. This method is used when the content of the log file is re-written on every write. |
|
ReplaceFileNamePattern ( string pattern, string replacementValue ) : string |
Replaces the string-based pattern i.e. {#} in a file name with the value passed in
|
|
ReplaceNumberPattern ( string pattern, int value ) : string |
Replaces the numeric pattern i.e. {#} in a file name with the value parameter value.
|
|
RollArchivesForward ( string fileName, string pattern, int archiveNumber ) : void |
Archives the fileName using a rolling style numbering (the most recent is always #0 then #1, ..., #N. When the number of archive files exceed P:MaxArchiveFiles the obsolete archives are deleted. This method is called recursively. This is the reason the archiveNumber is required. |
|
ShouldDeleteOldArchives ( ) : bool |
Determine if old archive files should be deleted.
|
|
StopAppenderInvalidatorThread ( ) : void | ||
TryArchiveFile ( string fileName, LogEventInfo ev, int upcomingWriteSize ) : void |
Archives the file if it should be archived.
|
|
TryParseDateAndSequence ( string archiveFileNameWithoutPath, string dateFormat, FileNameTemplate fileTemplate, System.DateTime &date, int &sequence ) : bool |
Parse filename with date and sequence pattern
|
|
WriteFooter ( string fileName ) : void |
Writes the footer information to a file.
|
|
WriteHeader ( |
Writes the header information to a file.
|
|
WriteToFile ( string fileName, LogEventInfo logEvent, byte bytes, bool justData ) : void |
Evaluates which parts of a file should be written (header, content, footer) based on various properties of FileTarget instance and writes them.
|
public CleanupInitializedFiles ( System.DateTime cleanupThreshold ) : void | ||
cleanupThreshold | System.DateTime | The cleanup threshold. |
리턴 | void |
public FileTarget ( string name ) : System | ||
name | string | Name of the target. |
리턴 | System |
protected FlushAsync ( AsyncContinuation asyncContinuation ) : void | ||
asyncContinuation | AsyncContinuation | The asynchronous continuation. |
리턴 | void |
protected GetBytesToWrite ( LogEventInfo logEvent ) : byte[] | ||
logEvent | LogEventInfo | Log event. |
리턴 | byte[] |
protected GetFormattedMessage ( LogEventInfo logEvent ) : string | ||
logEvent | LogEventInfo | The log event to be formatted. |
리턴 | string |
protected TransformBytes ( byte value ) : byte[] | ||
value | byte | The byte array. |
리턴 | byte[] |
protected Write ( NLog.Common.AsyncLogEventInfo logEvents ) : void | ||
logEvents | NLog.Common.AsyncLogEventInfo | An array of |
리턴 | void |
protected Write ( LogEventInfo logEvent ) : void | ||
logEvent | LogEventInfo | The logging event. |
리턴 | void |