Beispiel #1
0
        /// <summary>
        /// Empty method so the static constructor initializes the root logger.
        /// </summary>
        public static void StartLogging(LogFilePath logFilePath)
        {
            var hierarchy = GetDefaultLoggerHierarchy();

            var patternLayoutRollingFile = GetPatternLayoutRollingFile();
            var rollingFileAppender      = GetRollingFileAppender(patternLayoutRollingFile, logFilePath);

            hierarchy.Root.AddAppender(rollingFileAppender);

            hierarchy.Root.Level = DefaultLoggingLevel;
            hierarchy.Configured = true;
        }
Beispiel #2
0
        /// <summary>
        /// Get the activated rolling file appender.
        /// </summary>
        /// <param name="patternLayout"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private static RollingFileAppender GetRollingFileAppender(PatternLayout patternLayout, LogFilePath filePath)
        {
            var rollingFileAppender = new RollingFileAppender
            {
                AppendToFile       = true,
                File               = filePath.Path,
                Layout             = patternLayout,
                MaxSizeRollBackups = 5,
                MaximumFileSize    = "10MB",
                RollingStyle       = RollingFileAppender.RollingMode.Size,
                StaticLogFileName  = true
            };

            ActivateOptions(rollingFileAppender);
            return(rollingFileAppender);
        }
 protected bool Equals(LogFilePath other)
 {
     return(string.Equals(Path, other.Path, StringComparison.InvariantCultureIgnoreCase));
 }