Gets logging working in netcore, removes remaining usages of AppDomain.CurrentDomain.BaseDirectory and reduces more IOHelper usages
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -176,3 +176,4 @@ build/temp/
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/lib/*
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/views/*
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/App_Data/TEMP/*
|
||||
/src/Umbraco.Web.UI.NetCore/App_Data/Logs/*
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.Diagnostics
|
||||
@@ -100,7 +101,7 @@ namespace Umbraco.Core.Diagnostics
|
||||
return bRet;
|
||||
}
|
||||
|
||||
public static bool Dump(IMarchal marchal, IIOHelper ioHelper, Option options = Option.WithFullMemory, bool withException = false)
|
||||
public static bool Dump(IMarchal marchal, IHostingEnvironment hostingEnvironment, Option options = Option.WithFullMemory, bool withException = false)
|
||||
{
|
||||
lock (LockO)
|
||||
{
|
||||
@@ -110,7 +111,7 @@ namespace Umbraco.Core.Diagnostics
|
||||
// filter everywhere in our code = not!
|
||||
var stacktrace = withException ? Environment.StackTrace : string.Empty;
|
||||
|
||||
var filepath = ioHelper.MapPath("~/App_Data/MiniDump");
|
||||
var filepath = Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data/MiniDump");
|
||||
if (Directory.Exists(filepath) == false)
|
||||
Directory.CreateDirectory(filepath);
|
||||
|
||||
@@ -122,11 +123,11 @@ namespace Umbraco.Core.Diagnostics
|
||||
}
|
||||
}
|
||||
|
||||
public static bool OkToDump(IIOHelper ioHelper)
|
||||
public static bool OkToDump(IHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
lock (LockO)
|
||||
{
|
||||
var filepath = ioHelper.MapPath("~/App_Data/MiniDump");
|
||||
var filepath = Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data/MiniDump");
|
||||
if (Directory.Exists(filepath) == false) return true;
|
||||
var count = Directory.GetFiles(filepath, "*.dmp").Length;
|
||||
return count < 8;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Serilog;
|
||||
using Serilog.Configuration;
|
||||
@@ -29,11 +30,9 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
{
|
||||
global::Serilog.Debugging.SelfLog.Enable(msg => System.Diagnostics.Debug.WriteLine(msg));
|
||||
|
||||
// TODO: we can't use AppDomain.CurrentDomain.BaseDirectory, need a consistent approach between netcore/netframework
|
||||
|
||||
//Set this environment variable - so that it can be used in external config file
|
||||
//add key="serilog:write-to:RollingFile.pathFormat" value="%BASEDIR%\logs\log.txt" />
|
||||
Environment.SetEnvironmentVariable("BASEDIR", AppDomain.CurrentDomain.BaseDirectory, EnvironmentVariableTarget.Process);
|
||||
Environment.SetEnvironmentVariable("BASEDIR", hostingEnvironment.ApplicationPhysicalPath, EnvironmentVariableTarget.Process);
|
||||
Environment.SetEnvironmentVariable("MACHINENAME", Environment.MachineName, EnvironmentVariableTarget.Process);
|
||||
|
||||
logConfig.MinimumLevel.Verbose() //Set to highest level of logging (as any sinks may want to restrict it to Errors only)
|
||||
@@ -57,13 +56,11 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// <param name="logConfig">A Serilog LoggerConfiguration</param>
|
||||
/// <param name="minimumLevel">The log level you wish the JSON file to collect - default is Verbose (highest)</param>
|
||||
/// <param name="retainedFileCount">The number of days to keep log files. Default is set to null which means all logs are kept</param>
|
||||
public static LoggerConfiguration OutputDefaultTextFile(this LoggerConfiguration logConfig, LogEventLevel minimumLevel = LogEventLevel.Verbose, int? retainedFileCount = null)
|
||||
public static LoggerConfiguration OutputDefaultTextFile(this LoggerConfiguration logConfig, IHostingEnvironment hostingEnvironment, LogEventLevel minimumLevel = LogEventLevel.Verbose, int? retainedFileCount = null)
|
||||
{
|
||||
// TODO: we can't use AppDomain.CurrentDomain.BaseDirectory, need a consistent approach between netcore/netframework
|
||||
|
||||
//Main .txt logfile - in similar format to older Log4Net output
|
||||
//Ends with ..txt as Date is inserted before file extension substring
|
||||
logConfig.WriteTo.File($@"{AppDomain.CurrentDomain.BaseDirectory}\App_Data\Logs\UmbracoTraceLog.{Environment.MachineName}..txt",
|
||||
logConfig.WriteTo.File(Path.Combine(hostingEnvironment.ApplicationPhysicalPath, $@"App_Data\Logs\UmbracoTraceLog.{Environment.MachineName}..txt"),
|
||||
shared: true,
|
||||
rollingInterval: RollingInterval.Day,
|
||||
restrictedToMinimumLevel: minimumLevel,
|
||||
@@ -117,13 +114,11 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// <param name="logConfig">A Serilog LoggerConfiguration</param>
|
||||
/// <param name="minimumLevel">The log level you wish the JSON file to collect - default is Verbose (highest)</param>
|
||||
/// <param name="retainedFileCount">The number of days to keep log files. Default is set to null which means all logs are kept</param>
|
||||
public static LoggerConfiguration OutputDefaultJsonFile(this LoggerConfiguration logConfig, LogEventLevel minimumLevel = LogEventLevel.Verbose, int? retainedFileCount = null)
|
||||
public static LoggerConfiguration OutputDefaultJsonFile(this LoggerConfiguration logConfig, IHostingEnvironment hostingEnvironment, LogEventLevel minimumLevel = LogEventLevel.Verbose, int? retainedFileCount = null)
|
||||
{
|
||||
// TODO: we can't use AppDomain.CurrentDomain.BaseDirectory, need a consistent approach between netcore/netframework
|
||||
|
||||
//.clef format (Compact log event format, that can be imported into local SEQ & will make searching/filtering logs easier)
|
||||
//Ends with ..txt as Date is inserted before file extension substring
|
||||
logConfig.WriteTo.File(new CompactJsonFormatter(), $@"{AppDomain.CurrentDomain.BaseDirectory}\App_Data\Logs\UmbracoTraceLog.{Environment.MachineName}..json",
|
||||
logConfig.WriteTo.File(new CompactJsonFormatter(), Path.Combine(hostingEnvironment.ApplicationPhysicalPath, $@"App_Data\Logs\UmbracoTraceLog.{Environment.MachineName}..json"),
|
||||
shared: true,
|
||||
rollingInterval: RollingInterval.Day, //Create a new JSON file every day
|
||||
retainedFileCountLimit: retainedFileCount, //Setting to null means we keep all files - default is 31 days
|
||||
@@ -137,12 +132,10 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// That allows the main logging pipeline to be configured
|
||||
/// </summary>
|
||||
/// <param name="logConfig">A Serilog LoggerConfiguration</param>
|
||||
public static LoggerConfiguration ReadFromConfigFile(this LoggerConfiguration logConfig)
|
||||
public static LoggerConfiguration ReadFromConfigFile(this LoggerConfiguration logConfig, IHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
// TODO: we can't use AppDomain.CurrentDomain.BaseDirectory, need a consistent approach between netcore/netframework
|
||||
|
||||
//Read from main serilog.config file
|
||||
logConfig.ReadFrom.AppSettings(filePath: AppDomain.CurrentDomain.BaseDirectory + @"\config\serilog.config");
|
||||
logConfig.ReadFrom.AppSettings(filePath: Path.Combine(hostingEnvironment.ApplicationPhysicalPath, @"config\serilog.config"));
|
||||
|
||||
return logConfig;
|
||||
}
|
||||
@@ -152,13 +145,11 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// That allows a separate logging pipeline to be configured that will not affect the main Umbraco log
|
||||
/// </summary>
|
||||
/// <param name="logConfig">A Serilog LoggerConfiguration</param>
|
||||
public static LoggerConfiguration ReadFromUserConfigFile(this LoggerConfiguration logConfig)
|
||||
public static LoggerConfiguration ReadFromUserConfigFile(this LoggerConfiguration logConfig, IHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
// TODO: we can't use AppDomain.CurrentDomain.BaseDirectory, need a consistent approach between netcore/netframework
|
||||
|
||||
//A nested logger - where any user configured sinks via config can not effect the main 'umbraco' logger above
|
||||
logConfig.WriteTo.Logger(cfg =>
|
||||
cfg.ReadFrom.AppSettings(filePath: AppDomain.CurrentDomain.BaseDirectory + @"\config\serilog.user.config"));
|
||||
cfg.ReadFrom.AppSettings(filePath: Path.Combine(hostingEnvironment.ApplicationPhysicalPath, @"config\serilog.user.config")));
|
||||
|
||||
return logConfig;
|
||||
}
|
||||
|
||||
@@ -19,30 +19,28 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
public class SerilogLogger : ILogger, IDisposable
|
||||
{
|
||||
private readonly ICoreDebugSettings _coreDebugSettings;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IMarchal _marchal;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a new instance of the <see cref="SerilogLogger"/> class with a configuration file.
|
||||
/// </summary>
|
||||
/// <param name="logConfigFile"></param>
|
||||
public SerilogLogger(ICoreDebugSettings coreDebugSettings, IIOHelper ioHelper, IMarchal marchal, FileInfo logConfigFile)
|
||||
public SerilogLogger(ICoreDebugSettings coreDebugSettings, IHostingEnvironment hostingEnvironment, IMarchal marchal, FileInfo logConfigFile)
|
||||
{
|
||||
_coreDebugSettings = coreDebugSettings;
|
||||
_ioHelper = ioHelper;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_marchal = marchal;
|
||||
|
||||
// TODO: we can't use AppDomain.CurrentDomain.BaseDirectory, need a consistent approach between netcore/netframework
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.AppSettings(filePath: AppDomain.CurrentDomain.BaseDirectory + logConfigFile)
|
||||
.ReadFrom.AppSettings(filePath: logConfigFile.FullName)
|
||||
.CreateLogger();
|
||||
}
|
||||
|
||||
public SerilogLogger(ICoreDebugSettings coreDebugSettings, IIOHelper ioHelper, IMarchal marchal, LoggerConfiguration logConfig)
|
||||
public SerilogLogger(ICoreDebugSettings coreDebugSettings, IHostingEnvironment hostingEnvironment, IMarchal marchal, LoggerConfiguration logConfig)
|
||||
{
|
||||
_coreDebugSettings = coreDebugSettings;
|
||||
_ioHelper = ioHelper;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_marchal = marchal;
|
||||
|
||||
//Configure Serilog static global logger with config passed in
|
||||
@@ -58,10 +56,10 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
var loggerConfig = new LoggerConfiguration();
|
||||
loggerConfig
|
||||
.MinimalConfiguration(hostingEnvironment, sessionIdResolver, requestCacheGetter)
|
||||
.ReadFromConfigFile()
|
||||
.ReadFromUserConfigFile();
|
||||
.ReadFromConfigFile(hostingEnvironment)
|
||||
.ReadFromUserConfigFile(hostingEnvironment);
|
||||
|
||||
return new SerilogLogger(coreDebugSettings, ioHelper, marchal, loggerConfig);
|
||||
return new SerilogLogger(coreDebugSettings, hostingEnvironment, marchal, loggerConfig);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -184,14 +182,14 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
dump = _coreDebugSettings.DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
|
||||
// dump if it is ok to dump (might have a cap on number of dump...)
|
||||
dump &= MiniDump.OkToDump(_ioHelper);
|
||||
dump &= MiniDump.OkToDump(_hostingEnvironment);
|
||||
}
|
||||
|
||||
if (dump)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dumped = MiniDump.Dump(_marchal, _ioHelper, withException: true);
|
||||
var dumped = MiniDump.Dump(_marchal, _hostingEnvironment, withException: true);
|
||||
messageTemplate += dumped
|
||||
? "\r\nA minidump was created in App_Data/MiniDump"
|
||||
: "\r\nFailed to create a minidump";
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace Umbraco.Tests.Testing
|
||||
profiler = Mock.Of<IProfiler>();
|
||||
break;
|
||||
case UmbracoTestOptions.Logger.Serilog:
|
||||
logger = new SerilogLogger(TestHelper.CoreDebugSettings, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTestFiles("~/unit-test.config")));
|
||||
logger = new SerilogLogger(TestHelper.CoreDebugSettings, HostingEnvironment, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTestFiles("~/unit-test.config")));
|
||||
profiler = new LogProfiler(logger);
|
||||
break;
|
||||
case UmbracoTestOptions.Logger.Console:
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
public void InitializeFixture()
|
||||
{
|
||||
|
||||
var logger = new SerilogLogger(TestHelper.CoreDebugSettings, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTestFiles("~/unit-test.config")));
|
||||
var logger = new SerilogLogger(TestHelper.CoreDebugSettings, HostingEnvironment, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTestFiles("~/unit-test.config")));
|
||||
_profilingLogger = new ProfilingLogger(logger, new LogProfiler(logger));
|
||||
}
|
||||
|
||||
|
||||
41
src/Umbraco.Web.UI.NetCore/Config/serilog.Release.config
Normal file
41
src/Umbraco.Web.UI.NetCore/Config/serilog.Release.config
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
|
||||
<!-- Used to toggle the log levels for the main Umbraco log files -->
|
||||
<!-- Found at /app_data/logs/ -->
|
||||
<!-- NOTE: Changing this will also flow down into serilog.user.config -->
|
||||
<!-- VALID Values: Verbose, Debug, Information, Warning, Error, Fatal -->
|
||||
<add key="serilog:minimum-level" value="Information" />
|
||||
|
||||
<!-- NOTE: This is how sources can have a different level -->
|
||||
<!--
|
||||
<add key="serilog:minimum-level:override:Umbraco.Core.Composing.TypeLoader" value="Warning" />
|
||||
-->
|
||||
|
||||
<!-- NOTE: Only one logger below can be enabled, you cannot log JSON & TXT files at the same time -->
|
||||
|
||||
<!-- Default JSON log file -->
|
||||
<!-- This is used by the default log viewer in the Umbraco backoffice -->
|
||||
<add key="serilog:using:File" value="Umbraco.Infrastructure" />
|
||||
<add key="serilog:write-to:File.formatter" value="Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact" />
|
||||
<add key="serilog:write-to:File.path" value="%BASEDIR%\App_Data\Logs\UmbracoTraceLog.%MACHINENAME%..json" />
|
||||
<add key="serilog:write-to:File.restrictedToMinimumLevel" value="Debug" />
|
||||
<add key="serilog:write-to:File.retainedFileCountLimit" value="" /> <!-- Number of log files to keep (or remove value to keep all files) -->
|
||||
<add key="serilog:write-to:File.rollingInterval" value="Day" /> <!-- Create a new log file every Minute/Hour/Day/Month/Year/infinite -->
|
||||
|
||||
|
||||
<!-- Optional TXT log file -->
|
||||
<!--<add key="serilog:using:File" value="Serilog.Sinks.File" /> -->
|
||||
<!--<add key="serilog:write-to:File.path" value="%BASEDIR%\App_Data\Logs\UmbracoTraceLog.%MACHINENAME%..txt" /> -->
|
||||
<!--<add key="serilog:write-to:File.shared" value="true" /> -->
|
||||
<!--<add key="serilog:write-to:File.restrictedToMinimumLevel" value="Debug" /> -->
|
||||
<!--<add key="serilog:write-to:File.retainedFileCountLimit" value="" /> --> <!-- Number of log files to keep (or remove value to keep all files) -->
|
||||
<!--<add key="serilog:write-to:File.rollingInterval" value="Day" /> --> <!-- Create a new log file every Minute/Hour/Day/Month/Year/infinite -->
|
||||
<!--<add key="serilog:write-to:File.outputTemplate" value="{Timestamp:yyyy-MM-dd HH:mm:ss,fff} [P{ProcessId}/D{AppDomainId}/T{ThreadId}] {Log4NetLevel} {SourceContext} - {Message:lj}{NewLine}{Exception}" /> -->
|
||||
|
||||
<!-- To write to new log locations (aka Sinks) such as your own .txt files with filtering, ELMAH.io, Elastic, SEQ -->
|
||||
<!-- Please use the serilog.user.config file to configure your own logging needs -->
|
||||
|
||||
</appSettings>
|
||||
</configuration>
|
||||
41
src/Umbraco.Web.UI.NetCore/Config/serilog.config
Normal file
41
src/Umbraco.Web.UI.NetCore/Config/serilog.config
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
|
||||
<!-- Used to toggle the log levels for the main Umbraco log files -->
|
||||
<!-- Found at /app_data/logs/ -->
|
||||
<!-- NOTE: Changing this will also flow down into serilog.user.config -->
|
||||
<!-- VALID Values: Verbose, Debug, Information, Warning, Error, Fatal -->
|
||||
<add key="serilog:minimum-level" value="Information" />
|
||||
|
||||
<!-- NOTE: This is how sources can have a different level -->
|
||||
<!--
|
||||
<add key="serilog:minimum-level:override:Umbraco.Core.Composing.TypeLoader" value="Warning" />
|
||||
-->
|
||||
|
||||
<!-- NOTE: Only one logger below can be enabled, you cannot log JSON & TXT files at the same time -->
|
||||
|
||||
<!-- Default JSON log file -->
|
||||
<!-- This is used by the default log viewer in the Umbraco backoffice -->
|
||||
<add key="serilog:using:File" value="Umbraco.Infrastructure" />
|
||||
<add key="serilog:write-to:File.formatter" value="Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact" />
|
||||
<add key="serilog:write-to:File.path" value="%BASEDIR%\App_Data\Logs\UmbracoTraceLog.%MACHINENAME%..json" />
|
||||
<add key="serilog:write-to:File.restrictedToMinimumLevel" value="Debug" />
|
||||
<add key="serilog:write-to:File.retainedFileCountLimit" value="" /> <!-- Number of log files to keep (or remove value to keep all files) -->
|
||||
<add key="serilog:write-to:File.rollingInterval" value="Day" /> <!-- Create a new log file every Minute/Hour/Day/Month/Year/infinite -->
|
||||
|
||||
|
||||
<!-- Optional TXT log file -->
|
||||
<!--<add key="serilog:using:File" value="Serilog.Sinks.File" /> -->
|
||||
<!--<add key="serilog:write-to:File.path" value="%BASEDIR%\App_Data\Logs\UmbracoTraceLog.%MACHINENAME%..txt" /> -->
|
||||
<!--<add key="serilog:write-to:File.shared" value="true" /> -->
|
||||
<!--<add key="serilog:write-to:File.restrictedToMinimumLevel" value="Debug" /> -->
|
||||
<!--<add key="serilog:write-to:File.retainedFileCountLimit" value="" /> --> <!-- Number of log files to keep (or remove value to keep all files) -->
|
||||
<!--<add key="serilog:write-to:File.rollingInterval" value="Day" /> --> <!-- Create a new log file every Minute/Hour/Day/Month/Year/infinite -->
|
||||
<!--<add key="serilog:write-to:File.outputTemplate" value="{Timestamp:yyyy-MM-dd HH:mm:ss,fff} [P{ProcessId}/D{AppDomainId}/T{ThreadId}] {Log4NetLevel} {SourceContext} - {Message:lj}{NewLine}{Exception}" /> -->
|
||||
|
||||
<!-- To write to new log locations (aka Sinks) such as your own .txt files with filtering, ELMAH.io, Elastic, SEQ -->
|
||||
<!-- Please use the serilog.user.config file to configure your own logging needs -->
|
||||
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
|
||||
<!-- Controls log levels for all user-defined child sub-logger sinks configured here (Set this higher than child sinks defined here) -->
|
||||
<!-- VALID Values: Verbose, Debug, Information, Warning, Error, Fatal -->
|
||||
<add key="serilog:minimum-level" value="Information" />
|
||||
|
||||
<!-- For Different Namespaces - Set different logging levels -->
|
||||
<!--
|
||||
<add key="serilog:minimum-level:override:Microsoft" value="Warning" />
|
||||
<add key="serilog:minimum-level:override:Microsoft.AspNetCore.Mvc" value="Error" />
|
||||
<add key="serilog:minimum-level:override:YourNameSpace" value="Information" />
|
||||
-->
|
||||
|
||||
<!-- All logs defined via user.config will contain this property (won't be in main Umbraco logs) -->
|
||||
<!--
|
||||
<add key="serilog:enrich:with-property:websiteName" value="My Awesome Website - Development" />
|
||||
-->
|
||||
|
||||
<!-- Write to a user log file -->
|
||||
<!--
|
||||
<add key="serilog:using:File" value="Serilog.Sinks.File" />
|
||||
<add key="serilog:write-to:File.path" value="%BASEDIR%\logs\my-custom-logfile.txt" />
|
||||
<add key="serilog:write-to:File.shared" value="true" />
|
||||
<add key="serilog:write-to:File.restrictedToMinimumLevel" value="Debug" />
|
||||
<add key="serilog:write-to:File.retainedFileCountLimit" value="32" />--> <!-- Number of log files to keep (or remove value to keep all files) -->
|
||||
<!--<add key="serilog:write-to:File.rollingInterval" value="Day" />--> <!-- Create a new log file every Minute/Hour/Day/Month/Year/infinite -->
|
||||
<!--<add key="serilog:write-to:File.outputTemplate" value="{Timestamp:yyyy-MM-dd HH:mm:ss,fff} [P{ProcessId}/D{AppDomainId}/T{ThreadId}] {Log4NetLevel} {SourceContext} - {Message:lj}{NewLine}{Exception}" /> -->
|
||||
|
||||
<!-- Filters all above sink's to use this expression -->
|
||||
<!-- Common use case is to include SourceType starting with your own namespace -->
|
||||
<!--
|
||||
<add key="serilog:using:FilterExpressions" value="Serilog.Filters.Expressions" />
|
||||
<add key="serilog:filter:ByIncludingOnly.expression" value="StartsWith(SourceContext, 'Umbraco.Core')" />
|
||||
-->
|
||||
|
||||
</appSettings>
|
||||
</configuration>
|
||||
39
src/Umbraco.Web.UI.NetCore/Config/serilog.user.config
Normal file
39
src/Umbraco.Web.UI.NetCore/Config/serilog.user.config
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
|
||||
<!-- Controls log levels for all user-defined child sub-logger sinks configured here (Set this higher than child sinks defined here) -->
|
||||
<!-- VALID Values: Verbose, Debug, Information, Warning, Error, Fatal -->
|
||||
<add key="serilog:minimum-level" value="Information" />
|
||||
|
||||
<!-- For Different Namespaces - Set different logging levels -->
|
||||
<!--
|
||||
<add key="serilog:minimum-level:override:Microsoft" value="Warning" />
|
||||
<add key="serilog:minimum-level:override:Microsoft.AspNetCore.Mvc" value="Error" />
|
||||
<add key="serilog:minimum-level:override:YourNameSpace" value="Information" />
|
||||
-->
|
||||
|
||||
<!-- All logs defined via user.config will contain this property (won't be in main Umbraco logs) -->
|
||||
<!--
|
||||
<add key="serilog:enrich:with-property:websiteName" value="My Awesome Website - Development" />
|
||||
-->
|
||||
|
||||
<!-- Write to a user log file -->
|
||||
<!--
|
||||
<add key="serilog:using:File" value="Serilog.Sinks.File" />
|
||||
<add key="serilog:write-to:File.path" value="%BASEDIR%\logs\my-custom-logfile.txt" />
|
||||
<add key="serilog:write-to:File.shared" value="true" />
|
||||
<add key="serilog:write-to:File.restrictedToMinimumLevel" value="Debug" />
|
||||
<add key="serilog:write-to:File.retainedFileCountLimit" value="32" />--> <!-- Number of log files to keep (or remove value to keep all files) -->
|
||||
<!--<add key="serilog:write-to:File.rollingInterval" value="Day" />--> <!-- Create a new log file every Minute/Hour/Day/Month/Year/infinite -->
|
||||
<!--<add key="serilog:write-to:File.outputTemplate" value="{Timestamp:yyyy-MM-dd HH:mm:ss,fff} [P{ProcessId}/D{AppDomainId}/T{ThreadId}] {Log4NetLevel} {SourceContext} - {Message:lj}{NewLine}{Exception}" /> -->
|
||||
|
||||
<!-- Filters all above sink's to use this expression -->
|
||||
<!-- Common use case is to include SourceType starting with your own namespace -->
|
||||
<!--
|
||||
<add key="serilog:using:FilterExpressions" value="Serilog.Filters.Expressions" />
|
||||
<add key="serilog:filter:ByIncludingOnly.expression" value="StartsWith(SourceContext, 'Umbraco.Core')" />
|
||||
-->
|
||||
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -35,6 +35,11 @@
|
||||
<Content Remove="App_Data\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Config\serilog.Release.config" />
|
||||
<Content Remove="Config\serilog.user.Release.config" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Config\logviewer.searches.config.js" />
|
||||
</ItemGroup>
|
||||
@@ -43,4 +48,24 @@
|
||||
<Content Include="Config\logviewer.searches.config.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Config\serilog.Release.config">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>serilog.config</DependentUpon>
|
||||
</None>
|
||||
<None Include="Config\serilog.user.Release.config">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>serilog.user.config</DependentUpon>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="Config\serilog.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Update="Config\serilog.user.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user