/// <summary>
        ///     Initializes a new instance of the <see cref="LogWrittenEventArgs" /> class.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <param name="entriesWritten">The entries written.</param>
        /// <param name="rotateDetails">The rotate details.</param>
        /// <param name="purgeDetails">The purge details.</param>
        public LogWrittenEventArgs(string filename, int entriesWritten, RotateDetails rotateDetails = null, PurgeDetails purgeDetails = null)
        {
            Filename       = filename;
            EntriesWritten = entriesWritten;

            if (!string.IsNullOrEmpty(rotateDetails?.NewFilename))
            {
                RotateDetails = rotateDetails;
            }

            if (purgeDetails != null && ((purgeDetails.StaleFiles != null && purgeDetails.StaleFiles.Count > 0) || (purgeDetails.OverflowFiles != null && purgeDetails.OverflowFiles.Count > 0)))
            {
                PurgeDetails = purgeDetails;
            }
        }
        /// <summary>
        ///     Validate the current log file and check if any processing is required.
        /// </summary>
        private ValidateDetails Validate(bool generateValidateDetails = false)
        {
            try
            {
                RotateDetails rotateDetails = null;
                PurgeDetails  purgeDetails  = null;

                // Check the path of the log file
                // Check if the event log file should be rotated
                var fileInfo = new FileInfo(_path);
                if (fileInfo.Exists && fileInfo.Length >= _maxSize * 1024)
                {
                    // Rotate the current event log file
                    rotateDetails = Rotate(_path);

                    // Purge any stale event log files (every 10 rotations)
                    if (_rotationCount++ % 10 == 0)
                    {
                        purgeDetails = Purge(generateValidateDetails);
                    }
                }

                if (generateValidateDetails)
                {
                    return(new ValidateDetails(rotateDetails, purgeDetails));
                }

                return(null);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Failed to validate log file. {0}", ex);
            }

            return(null);
        }