serilog

Serilog Not Logging to Elasticsearch

爷,独闯天下 提交于 2020-03-05 02:01:12
问题 followed the Serilog Elasticsearch tutorial here: https://github.com/serilog/serilog-sinks-elasticsearch#handling-errors And nothing is working. I've seen other related SO posts that have suggestions + accepted answers but nothing is working. No errors, the console and file sinks work, however ES never gets written to. Here is the code that I am using: using System; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Serilog; using Serilog.Events; using Serilog.Formatting

Configure custom Column Options for Serilog Sinks MsSqlServer in AppSettings.json is not working

心已入冬 提交于 2020-03-03 08:55:31
问题 I'm trying to determine if it's possible to configure the column options for serilog sink mssqlserver in the appsettings.json file for an ASP.Net Core 3 project. besides not filling the custom columns, the database is also created in the standard way without these column, so I added them by hand. This could point to a configuration issue? The SQL to create the table CREATE TABLE [dbo].[logtable]( [Id] [int] IDENTITY(1,1) NOT NULL, [Message] [nvarchar](max) NULL, [MessageTemplate] [nvarchar]

Configure custom Column Options for Serilog Sinks MsSqlServer in AppSettings.json is not working

亡梦爱人 提交于 2020-03-03 08:55:11
问题 I'm trying to determine if it's possible to configure the column options for serilog sink mssqlserver in the appsettings.json file for an ASP.Net Core 3 project. besides not filling the custom columns, the database is also created in the standard way without these column, so I added them by hand. This could point to a configuration issue? The SQL to create the table CREATE TABLE [dbo].[logtable]( [Id] [int] IDENTITY(1,1) NOT NULL, [Message] [nvarchar](max) NULL, [MessageTemplate] [nvarchar]

Serilog : how do you specify a filter expression in config file

倖福魔咒の 提交于 2020-03-01 03:37:07
问题 I am trying to specify this filter in the appsettings .json file .Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.Hosting.Internal.WebHost")) The above syntax works when specified in c# But trying to specify the same in a json file does not work. "Filter": [ { "Name": "ByExcluding", "Args": { "expression": "Matching.FromSource = 'Microsoft.AspNetCore.Hosting.Internal.WebHost'" } } 回答1: You need to use Serilog.Filters.Expressions for this: Install-Package Serilog.Filters

Cannot resolve ILogger<T> Simple Injector ASP.NET Core 2.0

假装没事ソ 提交于 2020-02-27 06:28:25
问题 We use Simple Injector in ASP.NET Core application. Recently we've decided to use Serilog for logging purposes. Configuration was done in Program.cs as stated in their documentation. Then, in order to make Simple Injector able to resolve ILoggerFactory I did something like this: public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); // As per my understanding, we force SimpleInjector to use //

Serilog : Log to different files

≯℡__Kan透↙ 提交于 2020-01-23 04:28:05
问题 I am logging events of all types to single Json file irrespective of LogLevel. Now I have a requirement to log some custom performance counters to a seperate Json file. How can this be done in Serilog. Should I create different Logger Instance and use that where ever I am going to Log the performance counters? Want to use this with LibLog 回答1: You can do this by first making sure the performance counter events are tagged with either a particular property value ( OpenMappedContext() in LibLog)

Logging a literal message in NLog and/or Serilog

孤人 提交于 2020-01-16 13:18:19
问题 UPDATE: This turned out to be a discrepancy that exists in Serilog (which I tunnel to), but does not exist in NLog, which treats a single argument as a verbatim string (as one (and specifically, I) might expect) Using NLog, if I want to log something potentially containing embedded double braces: {{ without having them collapsed, what's the most efficient way? e.g.: NLog.LogManager.GetLogger("x").Warn("{{\"aaa}}") emits in my custom serilog-target: {"aaa} And I want: {{"aaa}} Is NLog

Serilog: How do I further enhance a filter expression in appsettings.json?

牧云@^-^@ 提交于 2020-01-15 07:47:13
问题 I have two loggers with Serilog and they save to different files. I want to create the loggers through the appsettings.json as opposed to code. When I create my loggers through the Startup.cs configuration, I get a much more specific log and I prefer to have it that way as it's much clearer and will allow others to check the logs and understand what's going on without needing much technical knowledge. However, I want to apply this to the appsettings so that I can migrate the code to any other

Serilog in Azure Functions

故事扮演 提交于 2020-01-14 08:47:32
问题 Each method in Azure Functions can have a Microsoft.Extensions.Logging.ILogger injected into it for logging. Using WebJobsStartup with a startup class you can change the logging to use Serilog using the following syntax: [assembly: WebJobsStartup(typeof(Startup))] namespace MyFuncApp { public class Startup : IWebJobsStartup { public void Configure(IWebJobsBuilder builder) { builder.Services.AddLogging( lb => lb.ClearProviders() .AddSerilog( new LoggerConfiguration() .Enrich.FromLogContext()

Serilog in Azure Functions

。_饼干妹妹 提交于 2020-01-14 08:47:03
问题 Each method in Azure Functions can have a Microsoft.Extensions.Logging.ILogger injected into it for logging. Using WebJobsStartup with a startup class you can change the logging to use Serilog using the following syntax: [assembly: WebJobsStartup(typeof(Startup))] namespace MyFuncApp { public class Startup : IWebJobsStartup { public void Configure(IWebJobsBuilder builder) { builder.Services.AddLogging( lb => lb.ClearProviders() .AddSerilog( new LoggerConfiguration() .Enrich.FromLogContext()