Exemple #1
0
        internal static AuditingOpticsLoggerSettings Load()
        {
            AuditingOpticsLoggerSettings.Tracer.TraceDebug(0L, "Start loading Auditing Optics log settings.");
            AuditingOpticsLoggerSettings auditingOpticsLoggerSettings = new AuditingOpticsLoggerSettings();
            BoolAppSettingsEntry         boolAppSettingsEntry         = new BoolAppSettingsEntry("LogEnabled", true, AuditingOpticsLoggerSettings.Tracer);

            auditingOpticsLoggerSettings.Enabled = boolAppSettingsEntry.Value;
            StringAppSettingsEntry stringAppSettingsEntry = new StringAppSettingsEntry("LogDirectoryPath", Path.Combine(ExchangeSetupContext.LoggingPath, AuditingOpticsConstants.LoggerComponentName), AuditingOpticsLoggerSettings.Tracer);

            auditingOpticsLoggerSettings.DirectoryPath = stringAppSettingsEntry.Value;
            TimeSpanAppSettingsEntry timeSpanAppSettingsEntry = new TimeSpanAppSettingsEntry("LogFileAgeInDays", TimeSpanUnit.Days, TimeSpan.FromDays(30.0), AuditingOpticsLoggerSettings.Tracer);

            auditingOpticsLoggerSettings.MaxAge = timeSpanAppSettingsEntry.Value;
            ByteQuantifiedSizeAppSettingsEntry byteQuantifiedSizeAppSettingsEntry = new ByteQuantifiedSizeAppSettingsEntry("LogDirectorySizeLimit", ByteQuantifiedSize.Parse("100MB"), AuditingOpticsLoggerSettings.Tracer);

            auditingOpticsLoggerSettings.MaxDirectorySize = byteQuantifiedSizeAppSettingsEntry.Value;
            ByteQuantifiedSizeAppSettingsEntry byteQuantifiedSizeAppSettingsEntry2 = new ByteQuantifiedSizeAppSettingsEntry("LogFileSizeLimit", ByteQuantifiedSize.Parse("10MB"), AuditingOpticsLoggerSettings.Tracer);

            auditingOpticsLoggerSettings.MaxFileSize = byteQuantifiedSizeAppSettingsEntry2.Value;
            ByteQuantifiedSizeAppSettingsEntry byteQuantifiedSizeAppSettingsEntry3 = new ByteQuantifiedSizeAppSettingsEntry("LogCacheSizeLimit", ByteQuantifiedSize.Parse("256KB"), AuditingOpticsLoggerSettings.Tracer);

            auditingOpticsLoggerSettings.CacheSize = byteQuantifiedSizeAppSettingsEntry3.Value;
            TimeSpanAppSettingsEntry timeSpanAppSettingsEntry2 = new TimeSpanAppSettingsEntry("LogFlushIntervalInSeconds", TimeSpanUnit.Seconds, TimeSpan.FromSeconds(60.0), AuditingOpticsLoggerSettings.Tracer);

            auditingOpticsLoggerSettings.FlushInterval = timeSpanAppSettingsEntry2.Value;
            auditingOpticsLoggerSettings.FlushToDisk   = true;
            AuditingOpticsLoggerSettings.Tracer.TraceDebug(0L, "The Auditing Optics log settings are loaded successfully.");
            return(auditingOpticsLoggerSettings);
        }
Exemple #2
0
        internal AuditingOpticsLoggerInstance(AuditingOpticsLoggerType loggerType)
        {
            EnumValidator.AssertValid <AuditingOpticsLoggerType>(loggerType);
            AuditingOpticsLoggerSettings auditingOpticsLoggerSettings = AuditingOpticsLoggerSettings.Load();

            if (auditingOpticsLoggerSettings.Enabled)
            {
                this.Enabled    = true;
                this.LoggerType = loggerType;
                if (this.IsDebugTraceEnabled())
                {
                    this.SafeTraceDebug(0L, "Start creating Auditing Optics log.", new object[0]);
                }
                this.LogSchema = new LogSchema(AuditingOpticsConstants.SoftwareName, "15.00.1497.012", this.LogTypeName, this.GetLogFields());
                LogHeaderFormatter headerFormatter = new LogHeaderFormatter(this.LogSchema);
                this.Logger = new Log(this.FileNamePrefix, headerFormatter, this.LogComponentName);
                if (this.IsDebugTraceEnabled())
                {
                    this.SafeTraceDebug(0L, "Start configuring the Auditing Optics log.", new object[0]);
                }
                this.Logger.Configure(Path.Combine(auditingOpticsLoggerSettings.DirectoryPath, this.FileNamePrefix), auditingOpticsLoggerSettings.MaxAge, (long)auditingOpticsLoggerSettings.MaxDirectorySize.ToBytes(), (long)auditingOpticsLoggerSettings.MaxFileSize.ToBytes(), (int)auditingOpticsLoggerSettings.CacheSize.ToBytes(), auditingOpticsLoggerSettings.FlushInterval, auditingOpticsLoggerSettings.FlushToDisk);
                if (this.IsDebugTraceEnabled())
                {
                    this.SafeTraceDebug(0L, "Auditing Optics log on server '{0}' is created and ready for use.", new object[]
                    {
                        this.ServerName
                    });
                    return;
                }
            }
            else
            {
                this.Enabled = false;
                if (this.IsDebugTraceEnabled())
                {
                    this.SafeTraceDebug(0L, "The Auditing Optics log is disabled.", new object[0]);
                }
            }
        }