serilog

Output JSON in Azure Function Logs

久未见 提交于 2020-07-23 06:30:51
问题 We'd like to send structured log data from our Azure Functions to Event Hub. So I set up Serilog to log to the console and include all the info I wanted. But now I come to try this in Azure, all of my nice Json formatted data from Serilog is being ignored - and only the standard ILogger output is being shown :( Here's the config I'm using in Startup.ConfigureServices . services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(CreateLogger())); private static Logger CreateLogger() { var

Serilog DI in ASP.NET Core, which ILogger interface to inject?

江枫思渺然 提交于 2020-07-22 14:11:31
问题 Context I've successfully configured Serilog in my ASP.NET Core application, only the DI part remains. Question Now I have two ILogger interfaces, one is Serilog.ILogger the other is Microsoft.Extensions.Logging.ILogger . Both works based on my Serilog config, and I do not know which to use? (I mean, after Serilog config in place Microsoft.Extensions.Logging.ILogger also correctly logging through Serilog, so my config is honored) In case Microsoft.Extensions.Logging.ILogger I do know how to

Why asp.net core logging everything?

眉间皱痕 提交于 2020-06-27 18:55:32
问题 I have creted my first asp.net core 3.0 application. And setup.cs file with serilog file extension like following: public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddControllers(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app

How to setup configuration in .NET Framework for Serilog

女生的网名这么多〃 提交于 2020-06-23 08:53:21
问题 Our team just moved one of our ASP.NET solutions from logging in log4net to Serilog (using iLogger) for logging. Our solution is .NET Framework 4.6. I can see Serilog configuration documentation online for setting up configuration in code as well as some documentation in appsettings.json. We have Web.config configuration files. Our old log4net configuration resided completely in the csproj files. Is there a place for configuration for Serilog and its sinks in .NET Framework (specifically in

Resolve generic Microsoft.Extensions.Logging.ILogger<T> with Unity - get InvalidCastException

橙三吉。 提交于 2020-06-15 08:28:57
问题 I am trying to register a generic ILogger (from Microsoft.Extensions.Logging, not from Serilog) in Unity (version 4). I've got the following class: public class MyClass { private readonly Microsoft.Extensions.Logging.ILogger<MyClass> _logger; public MyClass(Microsoft.Extensions.Logging.ILogger<MyClass> logger) { _logger = logger; } } And the following Unity registrations and test: // Arrange IUnityContainer container = new UnityContainer(); // provider from Serilog.Extensions.Logging nuget

Serilog multiple files appsettings.json

£可爱£侵袭症+ 提交于 2020-06-14 06:33:08
问题 Im trying to configure serilog to write to multiple files, with no luck whatsoever. With this configuration it just writes to the second file? { "AllowedHosts": "*", "Serilog": { "Using": [ "Serilog.Sinks.File" ], "MinimumLevel": "Debug", "WriteTo": [ { "Name": "File", "Args": { "path": "c:\\temp\\audit-.log", "rollingInterval": "Day", "restrictedToMinimumLevel": "Information" } }, { "Name": "File", "Args": { "path": "c:\\temp\\error-.log", "rollingInterval": "Day", "restrictedToMinimumLevel"

Using Asp.Net Core 2 Injection for Serilog with Multiple Projects

余生长醉 提交于 2020-06-09 10:28:44
问题 I have Serilog configured for Asp.Net Core 2.0 and it works great via .Net Core dependency injection in my startup web project (if I use it through Microsoft.Extensions.Logging), but I can't access it from any other project. Here's what I have: Program.cs using System; using System.IO; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Serilog; namespace ObApp.Web.Mvc { public class Program { public static IConfiguration

Using Asp.Net Core 2 Injection for Serilog with Multiple Projects

﹥>﹥吖頭↗ 提交于 2020-06-09 10:27:46
问题 I have Serilog configured for Asp.Net Core 2.0 and it works great via .Net Core dependency injection in my startup web project (if I use it through Microsoft.Extensions.Logging), but I can't access it from any other project. Here's what I have: Program.cs using System; using System.IO; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Serilog; namespace ObApp.Web.Mvc { public class Program { public static IConfiguration

Using Asp.Net Core 2 Injection for Serilog with Multiple Projects

孤者浪人 提交于 2020-06-09 10:26:28
问题 I have Serilog configured for Asp.Net Core 2.0 and it works great via .Net Core dependency injection in my startup web project (if I use it through Microsoft.Extensions.Logging), but I can't access it from any other project. Here's what I have: Program.cs using System; using System.IO; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Serilog; namespace ObApp.Web.Mvc { public class Program { public static IConfiguration

How to configure a Serilog sink for logging to CloudWatch

末鹿安然 提交于 2020-06-09 02:06:12
问题 I would appreciate some guidance in setting up a Serilog sink for AWS CloudWatch with .NET Core. I'm using appsettings.json for configuration but I am unable to put the settings in the logger. When trying to write log information to CloudWatch this error appears: An error occurred while starting the application. AmazonClientException: No RegionEndpoint or ServiceURL configured Amazon.Runtime.ClientConfig.Validate() in ClientConfig.cs, line 446 AmazonClientException: No RegionEndpoint or