serilog

How to override an ASP.NET Core configuration array setting using environment variables

主宰稳场 提交于 2019-11-28 07:13:05
LT;DR In an ASP.NET Core app I have an appsettings.json config file which uses a JSON array to configure a collection of settings. How do I override a setting of one of the array objects using environment variables? Background I'm using serilog in an ASP.NET core application and using the Serilog.Settings.Configuration , to allow it to be configured using appsettings.json . The configuration is like this: { "Serilog": { "Using": ["Serilog.Sinks.Literate"], "MinimumLevel": "Debug", "WriteTo": [ { "Name": "File", "Args": { "path": "%TEMP%\\Logs\\serilog-configuration-sample.txt" } } ], "Enrich":

Serilog - Output/Enrich All Messages with MethodName from which log entry was Called

时间秒杀一切 提交于 2019-11-28 06:38:25
Is there anyway to enrich all Serilog output with the Method Name. For Instance consider If I have the following; Public Class MyClassName Private Function MyFunctionName() As Boolean Logger.Information("Hello World") Return True End Function End Class The desired output would be as follows; 2015-04-06 18:41:35.361 +10:00 [Information] [MyFunctionName] Hello World! Actually the Fully Qualified Name would be good. 2015-04-06 18:41:35.361 +10:00 [Information] [MyClassName.MyFunctionName] Hello World! It seems that "Enrichers" are only good for Static Information and won't work each time. It's

Serilog MSSQL Sink doesn't write logs to database

冷暖自知 提交于 2019-11-28 06:06:19
问题 I have created a .Net class library (4.6.2) and created serilog implementation which is called by other interfaces such as console app. Now when I use File sink type, the logs are getting written to the files but with MSSQL sink, its not doing so. The log tables are getting created with column options as provided with autoCreateTable options ILogger logger = new LoggerConfiguration() .WriteTo.MSSqlServer(connectionString, tableName, autoCreateSqlTable: autoCreateSqlTable,

Serilog.Sinks.MSSqlServer not filling custom columns

北战南征 提交于 2019-11-28 00:06:42
问题 I've looked around, but I could not find a working solution, and since all examples look alike I assume it must be me overlooking something obvious. Also note this is my first real project using.NET Core and Serilog. The Problem I am trying to log (using serilog) some custom properties into their own columns in the database as defined in appsettings.json and added via middleware on the pipeline. But the values remain NULL, even though the same items are correctly filled in the properties XML

Serilog does not write log to file while using InProcess hosting model in ASP.NET Core 2.2

↘锁芯ラ 提交于 2019-11-27 09:31:41
If I use newly introduced InProcess hosting model in ASP.NET Core 2.2 as follows: <PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> </PropertyGroup> Serilog does not write log to file. but if I remove <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> from .csproj everything works as expected. My Serilog configuration in the Program class as follows: public class Program { public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() // Set the minimun log level

How to override an ASP.NET Core configuration array setting using environment variables

只谈情不闲聊 提交于 2019-11-27 05:42:42
问题 LT;DR In an ASP.NET Core app I have an appsettings.json config file which uses a JSON array to configure a collection of settings. How do I override a setting of one of the array objects using environment variables? Background I'm using serilog in an ASP.NET core application and using the Serilog.Settings.Configuration, to allow it to be configured using appsettings.json . The configuration is like this: { "Serilog": { "Using": ["Serilog.Sinks.Literate"], "MinimumLevel": "Debug", "WriteTo": [

Serilog - Output/Enrich All Messages with MethodName from which log entry was Called

耗尽温柔 提交于 2019-11-27 00:58:19
问题 Is there anyway to enrich all Serilog output with the Method Name. For Instance consider If I have the following; Public Class MyClassName Private Function MyFunctionName() As Boolean Logger.Information("Hello World") Return True End Function End Class The desired output would be as follows; 2015-04-06 18:41:35.361 +10:00 [Information] [MyFunctionName] Hello World! Actually the Fully Qualified Name would be good. 2015-04-06 18:41:35.361 +10:00 [Information] [MyClassName.MyFunctionName] Hello

Serilog - multiple log files

落花浮王杯 提交于 2019-11-26 19:37:44
问题 I am using Serilog for logging and cant' figure out how to separate log events to different files. For example, I want to log errors to error_log-ddmmyyyy.txt and warnings to warn_log-ddmmyyyy.txt. Here goes my logger configuration: Log.Logger = new LoggerConfiguration() .WriteTo.Logger(lc => lc.Filter.ByIncludingOnly(Matching.WithProperty("Level", "Warning")) .WriteTo.RollingFile( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Logs\warn_log-{Date}.txt"), outputTemplate: OutputTemplate

Serilog does not write log to file while using InProcess hosting model in ASP.NET Core 2.2

时光怂恿深爱的人放手 提交于 2019-11-26 14:46:53
问题 If I use newly introduced InProcess hosting model in ASP.NET Core 2.2 as follows: <PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> </PropertyGroup> Serilog does not write log to file. but if I remove <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> from .csproj everything works as expected. My Serilog configuration in the Program class as follows: public class Program { public static void Main(string[] args)