2,472 questions
Best practices
1
vote
1
replies
49
views
Using Spectre.Console.Cli with Generic Host
I have a CLI app in .NET, built with Spectre.Console.Cli package. I use ServiceCollection with Spectre ITypeResolver and ITypeRegistrar interfaces to wire up the DI. That works great, but now I want ...
1
vote
1
answer
33
views
.NET Serilog ReadFrom Configuration doesn't work
Working version:
private static void SetLogging(WebApplicationBuilder builder)
{
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.MinimumLevel.Override("...
1
vote
1
answer
107
views
Serilog PushProperty with additional properties
The code snippet below:
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.MinimumLevel.Verbose()
.WriteTo.Console(outputTemplate: "{Timestamp:HH:mm:ss} [{Level:u3}] {Message}{...
1
vote
0
answers
44
views
Serilog not logging after first request in ASP.NET Core Web API running as Windows service
I've been unable to figure this one out and am wondering if anyone has any ideas. This is an ASP.NET Core Web API running as a Windows service.
It will log to a file at the absolute path I specify for ...
0
votes
1
answer
54
views
Serilog xml-based config sublogger not working
I would like writing regular logs to log.csv, statistics info to separate log files. (.NET Framework 4.7.)
Instantiated in code - I want to keep it minimal and have purely xml-based config.
Log.Logger ...
0
votes
0
answers
30
views
Serilog tracing in Azure Functions using different triggers
I am trying to enable Serilog Tracing (serilog-tracing 2.3.1) in our system. It works well with http communication between our internal processes in my experiments. However, one of our components is ...
0
votes
1
answer
45
views
How can I overwrite one item in an array in the appsettings stack when the item is moderately complex? [closed]
I have an ASP.NET Core MVC app using Serilog. Sinks are configured in the appsettings.json. I have a few sinks.
One of the sinks is not behaving. Typically I would overwrite the values of the ...
1
vote
0
answers
59
views
Serilog ignores first sink in list from config file
I have a .net 8 api, using serilog to log various events.
Also have several sinks defined, console, file and SQL server
The issue I am having is that it appears that the first sink in the config file ...
2
votes
1
answer
109
views
How to do integration tests for Web API controller with Serilog setup configuration dependency?
My Program.cs file looks like this:
public class Program
{
private static IConfigurationRoot _apiConfiguration = null!;
public static async Task Main(string[] args)
{
try
{...
4
votes
1
answer
179
views
How to override the format, or the content of the log messages from Microsoft.AspNetCore.Hosting.Diagnostics?
Question from the title.
I'm trying to set up correlation Ids for my incoming requests. I have created a middleware, and set up a Serilog Enricher via EnrichDiagnosticContext (see code below). ...
1
vote
0
answers
58
views
Serilog loglevel override between Abstract Class and implementing class possible
I'm using Serilog to log to a SEQ server via a custom sink in my C# application. Many functionalities, including RPC server implementations, are derived from a company library, .Tools.
I'm ...
-5
votes
1
answer
59
views
How to force log output regardless of filter level for startup and shutdown events
I'm looking for the easiest / most elegant way to force log output for startup and shutdown events, regardless of the current output log level. This is so that logging to file will always have startup ...
0
votes
0
answers
94
views
Can I use Expression Templates for Serilog and AOT
I have an ExpressionTemplate that allows for ..dynamicProps as part of a log message.
This code is in my Program.cs file.
string jsonTemplate = "{ { timestamp: @t, level: @l, message: @m,"
...
3
votes
1
answer
146
views
Serilog use Expression Template and dynamic properties
I have a standard MessageTemplate that is defined in my Program.cs class that includes the usual properties:
string jsonOutputTemplate = "{ { ts: @t, lvl: @l, cid:CorrelationId, msg:@m, @x } }\n&...
0
votes
1
answer
81
views
Serilog - No logging on release app? What did I mess up?
I get no log output at all on my release app. Even when logging with logger.LogError() there is nothing added to any log file. I'm currently using Serilog for the first time inside a MAUI 9.0.40 ...
0
votes
1
answer
81
views
Serilog exclude database query log
I used to hide my SQL database logs from Console/Debug by adding this line of code in the Program.cs:
builder.Host.UseSerilog((builderContext, config) =>
{
config.ReadFrom.Configuration(...
1
vote
1
answer
289
views
Serilog configuration for .NET 8 Windows service not logging to file when deployed
I have an ASP.NET Core 8 Web API that is installed as a service using the following method:
var processInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
...
0
votes
1
answer
91
views
Serilog does not work using appsettings.json when deployed to App Service
I use Serilog for logging and want to write to Console and Application Insights.
Everything works fine on localhost. I see the logs in Console. But when I deploy it to Azure the App failed to start: &...
1
vote
0
answers
146
views
Serilog does not log Exceptions despite setting MinimumLevel to Information
I'm working on a ASP.NET Core MVC application and would like to use Serilog both for logging trace messages (Information) and Exceptions to Application Insight. The configuration code (from Program....
0
votes
2
answers
118
views
Excluding AppRequests in Serilog Azure App Insights Sink
I'm working on an ASP.NET application and using Azure AppInsights and Serilog Sink https://github.com/serilog-contrib/serilog-sinks-applicationinsights for pushing the logs. However one problem I have ...
1
vote
0
answers
112
views
How to force using existing index in Elastic.Serilog.Sinks
I have switched from Serilog.Sinks.Elasticsearch package to Elastic.Serilog.Sinks. Before I would specify target index name like this:
string indexFormat = settings.IndexName;
configuration
...
0
votes
1
answer
81
views
Extending logger to include user data
I currently use Serilog with the Ilogger extension where I log information in my .net core api.
As part of a requirement all logs that have a user registered must include the UserId in its logging.
...
0
votes
1
answer
151
views
Unable to see Datadog logs with Serilog.Sinks.Datadog.Logs Version 0.5.4 on Azure Function App
I am learning Azure Function Apps. My function app is a timer trigger that writes logs to datadog. The issue I am facing is related to the version incompatibility.
The below works (I can see logs on ...
0
votes
2
answers
198
views
Serilog send different output based on context
I'm using Serilog to log information on my app. I'm using an appsettings.json file (see below) to setup the configuration settings of the logger. In that file, I have two configurations - one for ...
1
vote
1
answer
146
views
SerilogTracing generates duplicate trace id for independent requests .NET 7
I added SEQ Tracing by using SerilogTracing in an ASP.NET Core 7 Web API using following code in program.cs:
var logger= new LoggerConfiguration()
.ReadFrom.Configuration(configuration);
using var ...