NLog.Targets.FileTarget.InitializeFile C# (CSharp) Method

InitializeFile() private method

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.
private InitializeFile ( string fileName, LogEventInfo logEvent, bool justData ) : bool
fileName string File name to be written.
logEvent LogEventInfo Log event that the instance is currently processing.
justData bool Indicates that only content section should be written in the file.
return bool
        private bool InitializeFile(string fileName, LogEventInfo logEvent, bool justData)
        {
            bool writeHeader = false;

            if (!justData)
            {
                //UtcNow is much faster then .now. This was a bottleneck in writing a lot of files after CPU test.
                var now = DateTime.UtcNow;
                if (!this.initializedFiles.ContainsKey(fileName))
                {
                    ProcessOnStartup(fileName, logEvent);

                    this.initializedFiles[fileName] = now;
                    this.initializedFilesCounter++;
                    writeHeader = true;

                    if (this.initializedFilesCounter >= FileTarget.InitializedFilesCounterMax)
                    {
                        this.initializedFilesCounter = 0;
                        this.CleanupInitializedFiles();
                    }
                }

                this.initializedFiles[fileName] = now;
            }

            return writeHeader;
        }