V11: Allow changing logging directory from configuration (#13485)
* Allow changing logging directory from configuration * Clean up * Missing return statement * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * Update src/Umbraco.Core/Constants-SystemDirectories.cs Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
// See LICENSE for more details.
|
||||
|
||||
using System.ComponentModel;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Umbraco.Cms.Core.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Configuration.Models;
|
||||
|
||||
@@ -12,10 +14,28 @@ namespace Umbraco.Cms.Core.Configuration.Models;
|
||||
public class LoggingSettings
|
||||
{
|
||||
internal const string StaticMaxLogAge = "1.00:00:00"; // TimeSpan.FromHours(24);
|
||||
internal const string StaticDirectory = Constants.SystemDirectories.LogFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for the maximum age of a log file.
|
||||
/// </summary>
|
||||
[DefaultValue(StaticMaxLogAge)]
|
||||
public TimeSpan MaxLogAge { get; set; } = TimeSpan.Parse(StaticMaxLogAge);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the folder to use for log files
|
||||
/// </summary>
|
||||
[DefaultValue(StaticDirectory)]
|
||||
public string Directory { get; set; } = StaticDirectory;
|
||||
|
||||
public string GetAbsoluteLoggingPath(IHostEnvironment hostEnvironment)
|
||||
{
|
||||
var dir = Directory;
|
||||
if (dir.StartsWith("~/"))
|
||||
{
|
||||
return hostEnvironment.MapPathContentRoot(dir);
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user