How can i add Domain name as a part of my Serilog file
The start up code is like below on Startup.cs file
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
SerilogConfig.Configure(services, Configuration);
....................
--------------
}
And the code of SerilogConfig is like
public class SerilogConfig
{
public static LoggingLevelSwitch? MyLoggingLevelSwitch { get; set; }
public static void Configure(IServiceCollection serviceCollection, IConfiguration configuration)
{
var baseLogPath = configuration["SeriLog:LogPath"];
if (string.IsNullOrEmpty(baseLogPath))
{
throw new Exception("SeriLog:LogPath is not set in the app.settings.");
}
var logLevel = configuration["SeriLog:LogLevel"];
if (string.IsNullOrEmpty(logLevel))
{
throw new Exception("SeriLog:LogLevel is not set in the app.settings.");
}
var deploymentMode = configuration["DeploymentMode"];
if (string.IsNullOrEmpty(deploymentMode))
{
throw new Exception("DeploymentMode is not set in the app.settings.");
}
var appName = configuration["ApplicationName"];
if (string.IsNullOrEmpty(appName))
{
throw new Exception("ApplicationName is not set in the app.settings.");
}
var rollbarAccessToken = configuration["RollbarAccessToken"];
if (string.IsNullOrWhiteSpace(rollbarAccessToken))
{
throw new Exception("RollbarAccessToken is not set in the web.config.");
}
var appLogName = $"{appName}-{deploymentMode.ToLower()}";
var detailedLogFile = baseLogPath + "\" + appLogName + $"-{DateTime.Now:yyyy-MM-dd}.log";
var outputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] <" + deploymentMode + "|{SourceContext}|{CorrelationId}> {Message}{NewLine}{NewLine}{Exception}{NewLine}";
-----------------
--------------------
------------------------
}
}
I can add the domain name / application name as a part of appsettings.json file, but in my case the website is hosted on IIS in a different way
There are 2 different websites exists in IIS , both of them pointing to the same directory / same appsettings.json file . Only the domain mapping is different.
So sites www.site1.com and www.site2.com is pointing to the same folder in IIS
So is there any way I can add the domain name / part of the domain name [ site1 / site2 ] to my Serilog log file