Removes all irrelevant logging settings from umbraco settings
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
internal class ExternalLoggerElement : ConfigurationElement
|
||||
{
|
||||
[ConfigurationProperty("assembly")]
|
||||
internal string Assembly
|
||||
{
|
||||
get { return (string)base["assembly"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("type")]
|
||||
internal string Type
|
||||
{
|
||||
get { return (string)base["type"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("logAuditTrail")]
|
||||
internal bool LogAuditTrail
|
||||
{
|
||||
get { return (bool)base["logAuditTrail"]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
public interface ILoggingSection : IUmbracoConfigurationSection
|
||||
{
|
||||
bool AutoCleanLogs { get; }
|
||||
|
||||
bool EnableLogging { get; }
|
||||
|
||||
int CleaningMiliseconds { get; }
|
||||
|
||||
int MaxLogAge { get; }
|
||||
|
||||
IEnumerable<ILogType> DisabledLogTypes { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,87 +6,16 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
internal class LoggingElement : UmbracoConfigurationElement, ILoggingSection
|
||||
{
|
||||
|
||||
[ConfigurationProperty("autoCleanLogs")]
|
||||
internal InnerTextConfigurationElement<bool> AutoCleanLogs
|
||||
{
|
||||
get { return GetOptionalTextElement("autoCleanLogs", false); }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("enableLogging")]
|
||||
internal InnerTextConfigurationElement<bool> EnableLogging
|
||||
{
|
||||
get { return GetOptionalTextElement("enableLogging", true); }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("enableAsyncLogging")]
|
||||
internal InnerTextConfigurationElement<bool> EnableAsyncLogging
|
||||
{
|
||||
get { return GetOptionalTextElement("enableAsyncLogging", true); }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("cleaningMiliseconds")]
|
||||
internal InnerTextConfigurationElement<int> CleaningMiliseconds
|
||||
{
|
||||
get { return GetOptionalTextElement("cleaningMiliseconds", -1); }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("maxLogAge")]
|
||||
internal InnerTextConfigurationElement<int> MaxLogAge
|
||||
{
|
||||
get { return GetOptionalTextElement("maxLogAge", -1); }
|
||||
}
|
||||
|
||||
[ConfigurationCollection(typeof(DisabledLogTypesCollection), AddItemName = "logTypeAlias")]
|
||||
[ConfigurationProperty("disabledLogTypes", IsDefaultCollection = true)]
|
||||
internal DisabledLogTypesCollection DisabledLogTypes
|
||||
{
|
||||
get { return (DisabledLogTypesCollection)base["disabledLogTypes"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("externalLogger", IsRequired = false)]
|
||||
internal ExternalLoggerElement ExternalLogger
|
||||
{
|
||||
get { return (ExternalLoggerElement) base["externalLogger"]; }
|
||||
}
|
||||
|
||||
public bool ExternalLoggerIsConfigured
|
||||
{
|
||||
get
|
||||
{
|
||||
var externalLoggerProperty = Properties["externalLogger"];
|
||||
var externalLogger = this[externalLoggerProperty] as ConfigurationElement;
|
||||
if (externalLogger != null && externalLogger.ElementInformation.IsPresent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ILoggingSection.AutoCleanLogs
|
||||
{
|
||||
get { return AutoCleanLogs; }
|
||||
}
|
||||
|
||||
bool ILoggingSection.EnableLogging
|
||||
{
|
||||
get { return EnableLogging; }
|
||||
}
|
||||
|
||||
int ILoggingSection.CleaningMiliseconds
|
||||
{
|
||||
get { return CleaningMiliseconds; }
|
||||
}
|
||||
|
||||
|
||||
int ILoggingSection.MaxLogAge
|
||||
{
|
||||
get { return MaxLogAge; }
|
||||
}
|
||||
|
||||
IEnumerable<ILogType> ILoggingSection.DisabledLogTypes
|
||||
{
|
||||
get { return DisabledLogTypes; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,6 @@
|
||||
<Compile Include="Configuration\UmbracoSettings\ContentImagingElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\ContentSectionExtensions.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\DisabledLogTypesCollection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\ExternalLoggerElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\FileExtensionElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\IBackOfficeSection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\IChar.cs" />
|
||||
|
||||
@@ -11,16 +11,6 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public override void DisabledLogTypes()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Logging.DisabledLogTypes.Any() == false);
|
||||
}
|
||||
[Test]
|
||||
public override void CleaningMiliseconds()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Logging.CleaningMiliseconds == -1);
|
||||
}
|
||||
[Test]
|
||||
public override void MaxLogAge()
|
||||
{
|
||||
|
||||
@@ -6,32 +6,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[TestFixture]
|
||||
public class LoggingElementTests : UmbracoSettingsTests
|
||||
{
|
||||
[Test]
|
||||
public void EnableLogging()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Logging.EnableLogging == true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public virtual void DisabledLogTypes()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Logging.DisabledLogTypes.Count() == 2);
|
||||
Assert.IsTrue(SettingsSection.Logging.DisabledLogTypes.ElementAt(0).LogTypeAlias == "[alias-of-log-type-in-lowercase]");
|
||||
Assert.IsTrue(SettingsSection.Logging.DisabledLogTypes.ElementAt(1).LogTypeAlias == "anotherlogalias");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AutoCleanLogs()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Logging.AutoCleanLogs == false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public virtual void CleaningMiliseconds()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Logging.CleaningMiliseconds == 86400);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public virtual void MaxLogAge()
|
||||
{
|
||||
|
||||
@@ -107,16 +107,7 @@
|
||||
</requestHandler>
|
||||
|
||||
<logging>
|
||||
<autoCleanLogs>false</autoCleanLogs>
|
||||
<enableLogging>true</enableLogging>
|
||||
<enableAsyncLogging>true</enableAsyncLogging>
|
||||
<disabledLogTypes>
|
||||
<logTypeAlias>[alias-of-log-type-in-lowercase]</logTypeAlias>
|
||||
<logTypeAlias>anotherlogalias</logTypeAlias>
|
||||
</disabledLogTypes>
|
||||
<cleaningMiliseconds>86400</cleaningMiliseconds>
|
||||
<maxLogAge>1440</maxLogAge>
|
||||
<externalLogger assembly="~/bin/assemblyFileName.dll" type="fully.qualified.namespace.and.type" logAuditTrail="false" />
|
||||
</logging>
|
||||
|
||||
<providers>
|
||||
|
||||
@@ -118,21 +118,6 @@
|
||||
</urlReplacing>
|
||||
</requestHandler>
|
||||
|
||||
<!--
|
||||
Now that we have external logging enabled, this section is only used for what gets logged to the umbracoLog table
|
||||
which currently logs items used in the audit trail and roll back scenarios.
|
||||
-->
|
||||
<logging>
|
||||
<enableLogging>true</enableLogging>
|
||||
<enableAsyncLogging>true</enableAsyncLogging>
|
||||
<disabledLogTypes>
|
||||
<!-- <logTypeAlias>[alias-of-log-type-in-lowercase]</logTypeAlias> -->
|
||||
</disabledLogTypes>
|
||||
<!-- You can add your own logging tool by implementing the umbraco.BusinessLogic.Interfaces.ILog interface and add the reference here -->
|
||||
<!-- The external logger can also act as the audit trail storage by setting the logAuditTrail attribute to true -->
|
||||
<!--<externalLogger assembly="~/bin/assemblyFileName.dll" type="fully.qualified.namespace.and.type" logAuditTrail="false" /> -->
|
||||
</logging>
|
||||
|
||||
<providers>
|
||||
<users>
|
||||
<!-- if you wish to use your own membershipprovider for authenticating to the umbraco back office -->
|
||||
|
||||
@@ -49,16 +49,7 @@ namespace Umbraco.Web.Scheduling
|
||||
|
||||
public static int GetLogScrubbingInterval(IUmbracoSettingsSection settings, ILogger logger)
|
||||
{
|
||||
var interval = 4 * 60 * 60 * 1000; // 4 hours, in milliseconds
|
||||
try
|
||||
{
|
||||
if (settings.Logging.CleaningMiliseconds > -1)
|
||||
interval = settings.Logging.CleaningMiliseconds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error<LogScrubber>(ex, "Unable to locate a log scrubbing interval. Defaulting to 4 hours.");
|
||||
}
|
||||
const int interval = 4 * 60 * 60 * 1000; // 4 hours, in milliseconds
|
||||
return interval;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user