Questions tagged [serilog]

1

votes
1

answer
739

Views

Enable file logging on IIS for serilog

I want to enable file logging on IIS to resolve an issue locally on IIS. Following is the code I am using. It works when I run on visual studio and logs to a file but not when I deployed to IIS. Folder has enough permission to create a file and also I created the folder and file. What am I missing h...
Charith
0

votes
2

answer
90

Views

Create a wrapper for Serilog

I'm using Serilog. To avoid configuration in each microservice I create a private NuGet package with extension like namespace DFX.Logging { public static class Extensions { public static IWebHostBuilder UseLogging(this IWebHostBuilder webHostBuilder) => webHostBuilder.UseSerilog((context, loggerConf...
Pr.Dumbledor
1

votes
2

answer
192

Views

Options for controlling Destructuring of request object

I've run into a problem that I'm struggling to find a clean solution for, and Googling has not made me any wiser. The situation (1) We have our own assembly for setting up and adding a Serilog logger to any of our projects (consistent logging output, theme, etc) and this assembly has no references t...
Mashton
1

votes
1

answer
103

Views

Serilog Seq package does not install on .NET Standard 2.0 library project

I created a .NET Standard 2.0 library project using Visual Studio and tried to install Seq as follows. Install-Package -Id Serilog.Sinks.Seq The top line of error says Unable to find package 'Serilog.Sinks.Seq' at source ''. Full detail is in this screenshot. Just as a comparison, installing the fo...
SamDevx
1

votes
0

answer
512

Views

Serilog Eventlog issue

I have asp.net core 2.0 project. I am using Serilog for logging. Here is my project file: netcoreapp2.0 aspnet-IdentityServerWithAspNetIdentity-04C6939F-E672-4E56-B4A5-5F064EB67F23 Pci.Services.IdentityServer4.Core Pci.Services.IdentityServer4.Core Always ..\..\..\..\Program Files (x86)\Reference As...
Manoj Kumar
1

votes
0

answer
232

Views

How to color the text logs file based on Error type in NLog

I am using Nlog library in my application to logs the files.It is logging the files in text format, but i need to color the text based on error type. logger.Info('Info error has occured'); - blue color. logger.Error('An error has occured' +ex.message); - Red color. But it is working fine in console...
Mohamed Sahir
1

votes
0

answer
395

Views

Override serilog properties based on source/context

Is there any way to override either a sink or a property in serilog based on source or context. For instance, I have this setup in an asp.net mvc core 2 project: Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .MinimumLevel.Override('Microsoft', LogEventLevel.Fatal) .Enrich.FromLogCon...
Dynde
1

votes
1

answer
313

Views

Proper way to print class names in log entries

Think I figured out a decent amount of Serilog to use in my application. However, I would like to 'enrich' the log with classnames and etc. (HTTP methods in future). Registered a global instance of Logger object in Autofac and calling it in other classes, but the lines written to log file are being...
Phani Anne
1

votes
2

answer
276

Views

Serilog Azure Table Storage and context properties

I'm trying to use AzureTableStorageWithProperties in Serilog.Sinks.AzureTableStorage, and I have a property that's attached to the context; something like this: using (LogContext.PushProperty('CameraId', camera.Id) { /* ... */ } So, I was wondering how I can configure the logger to consider this pro...
Farzad
1

votes
0

answer
91

Views

.NET Serilog: CreateLogger() now throw if called more than once

LoggerConfiguration loggerConfiguration = new LoggerConfiguration() .Enrich.With(new LogEnricher(User: userId, Name: Name)); _Logger = loggerConfiguration .Enrich.WithProperty('TimeStamp', DateTime.UtcNow) .Enrich.WithProperty('Level', LogLevel.Error) .WriteTo.Email( connectionInfo: new EmailConnect...
suman
1

votes
0

answer
259

Views

Serilog: rolling log file per day, but also per application run?

How can you configure Serilog to roll log files per day, but also have a new log file on every new application run? I didn't find a way for that, where my old log files would still be deleted. If I would name my log file like: string timestamp = DateTime.Now.ToString( 'yyyy-MM-dd_HH-mm-ss', DateTime...
Synthetiker
1

votes
1

answer
492

Views

Is there a way to enrich the log with a property from configuration?

I know I can add enrichers this way: { 'Serilog': { 'Using': [ 'Serilog', 'Serilog.Enrichers.Environment', 'Serilog.Enrichers.Process', ... ], 'Enrich': [ 'FromLogContext', 'WithMachineName', 'WithProcessId' ] ... Can I do the same for a property (ApplicationName)?
Paulo Morgado
1

votes
1

answer
462

Views

Serilog cannot show output logs aspnetcore 2.1 vs 2017

I am writing a few webapis using aspnetcore core 2.1 I would like to use serilog and I cannot find a simple example out there that works that gives me a starting point and shows me what I need to do. I would like to do the following Setup Serilog in appsetting.json file Write to VisualStudio outpu...
developer9969
1

votes
0

answer
203

Views

Custom ASP.NET Core Logger using Serilog

In my project I use Serilog and ASP.Net Core. The initialization part looks like that: var provider = services.BuildServiceProvider(); var logFactory = provider.GetRequiredService(); logFactory.AddSerilog().AddConsole(); return provider; This will add Serilog to the logging pipeline. I want to add t...
1

votes
0

answer
158

Views

Static logger aspnetcore webapi serilog

I am about to implement logging in some web apis I am writing. The default implementation suggests that everywhere I want to use logging I need to inject. What is wrong with a static logger(serilog)without the need of injecting everywhere. Am I missing the point? I did see this thread (before somebo...
developer9969
1

votes
0

answer
493

Views

Serilog and ASP.NET Core enrich `WithUserName` and `WithHttpRequestUserAgent`?

Is there a way to enrich Serilog log data in ASP.NET Core 2.1 application, similar to how enrichers WithUserNameand WithHttpRequestUserAgent work for classic ASP.NET (System.Web)? I tried implementing ILogEventEnricher interface, but it does not work, because I am not able to gain access to RequestC...
Nenad
1

votes
0

answer
35

Views

BeginScope in .Net Framework 4.5

I´ve worked with .NET Core recently and had pretty good experience with Serilog. Now I´m on a project which targets .NET Framework 4.5 and I´m looking for a way to use the BeginScope()-Functionality. This Method is part of Microsoft.Extensions.Logging -Namespace which can only be used with .NET S...
Joshit
1

votes
0

answer
33

Views

Liblog adapter for wix custom action

Currently I am logging Wix Custom Action log messages to a file using Session.Log(). My application uses Liblog with Serilog for logging. Is there a way to have an adapter class for Liblog that writes log messages to Custom Action Session? The reason for trying to write installer log messages using...
Kannan D
1

votes
1

answer
191

Views

Serilog: Create and track a unique log context for each request?

How would one go about preserving a unique log context for each request in a ASP.NET Core MVC application? I've been looking for some time at how I might accomplish this. I can only assume I'm missing something obvious. Basically, for instance, let's say I have an endpoint that accepts some payload....
ccoulter
1

votes
0

answer
130

Views

Write logs to ETW by serilog

Is there any way to write logs directly to ETW using serilog? I can't see any sinks or information on theirs website. I'm quite surprised that there is not etw sinks? Or maybe I'm wrong.
not_you
1

votes
0

answer
130

Views

Serilog build error - Indexed source information could not be retrieved

I am using nuget Serilog 2.7.1 in my project in visual studio 2017. Locally while building project it build successfully, but on build server it is giving me error - Indexed source information could not be retrieved from E:\Builds\21\ProjectName\Binaries\Project1\Serilog.pdb. Error: Symbol indexes c...
Mahesh Dounde
1

votes
1

answer
74

Views

How store Json Object to ELK using dotnet Logging

How can i store Json Object using dotnet logging interface. I'm using Serilog as provider. With this code i never see 'myObject' when i'm checking the log : public CommandResult Example(MyObject myObject) { try { logger.LogInformation('myObject is : ', myObject); //
btbenjamin
1

votes
1

answer
329

Views

resolve Microsoft.Extensions.Logging.ILogger from .NET Core class lib via AspNetCore WebApp utilizing Serilog.AspNetCore and AutofacSerilogIntegration

I am getting the following exception: Cannot resolve parameter 'Microsoft.Extensions.Logging.ILogger logger' 'At the moment (9/28/18), Serilog.AspNetCore doesn't get involved in DI/OoC configuration' Is it possible to register Serilog.Core.Logger as an implementation of Microsoft.Extensions.Logging....
RandyDaddis
1

votes
0

answer
38

Views

Send stringified json to serilog as structured data

I have: Serilog 2.7.1 .NET Framework 4.5.x I have a stringified JSON with different structures. Example: { 'dto': { 'id': '8d8cc96fa1b44186b28f2a90364e47d2', 'userName': 'case6', 'display': true, 'isFullUpdate': false } } I want to save it as structured data - not as stringified JSON. There are 2 wa...
1

votes
1

answer
36

Views

How to log field's names of message template in Serilog

Is there any setting in Serilog that tells to log names of variables in message template when output template is used? _logger.LogWarning(@'Role with Id {RoleId} not found', id); I use logging to file and want to see RoleId field logged in the file alongside with message so I could use filtering by...
Riddik
1

votes
0

answer
62

Views

All logged as if they are from the Main method

I am trying to use Serilog (both console and file) in a .NET Core console application. In my Main class I initialise my logger like this: Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .MinimumLevel.Override('Microsoft', LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.File(...
disasterkid
1

votes
0

answer
74

Views

How can a TextWriter be used as a source for Serilog?

StackExchange.Redis writes log messages to a TextWriter. It does not use the ILogger interface for logging. I would like to turn messages written to a TextWriter, into Serilog debug level messages. Thoughts?
Richard Collette
1

votes
1

answer
143

Views

.NET Core Serilog username is always null

I have added this middleware to add usernames to my logging, however, it always appears as null. This is the middleware private readonly RequestDelegate next; public LogUserName(RequestDelegate next) { this.next = next; } public async Task InvokeAsync(HttpContext context) { LogContext.PushProperty('...
JianYA
1

votes
0

answer
68

Views

Does Serilog console write to the IIS log file if stdoutLogEnabled is true?

I am using Core 2.2 with Serilog via a Console sink. Locally, this works great via Kestrel. My console opens and I get tons of logs. This changes when I go to IIS. If I flip stdoutLogEnabled to true, and I create a logs directory and give it 'Everyone - modify' ACL I do actually get a file, and I ge...
Victorio Berra
1

votes
0

answer
16

Views

How can I assign Event ID = 1 to all log entries written by Serilog.Sinks.EventLog

I have the following items in my App.COnfig and I can write to Windows Event Log However I see junk messages in Eventlog along with my main message: The description for Event ID 43413 from source MyXYZSource cannot be found. Either the component that raises this event is not installed on your local...
Allan Xu
1

votes
1

answer
32

Views

What is the idiomatic approach for logging long messages in a structured logging system like MEL and Serilog?

My ASP.NET Core 2.x web-application makes idiomatic use of Microsoft.Extensions.Logging for doing 'trace'-style logging when I want to store a short (
Dai
1

votes
1

answer
66

Views

Serilog, no error even if log file cannot be opened / created

I am looking into Serilog as an alternative to log4net (I have an issue where log4net stops logging with no clear way to recover from this). This is c#, mainly WinForms. First, here are the app.config settings: In the C# app, I create the logger like this: Log.Logger = new LoggerConfiguration() ....
Lars335
1

votes
0

answer
28

Views

Log File Depending on Property Selected in Class Attribute

I want to create a per file logger which will log to files depending on type and the specifications of an attribute on that type, but I'm having difficulty doing it in a trivial manner. So I would enumerate through all types using a LogOutputAttribute [System.AttributeUsage(AttributeTargets.Class, I...
FinalFortune
1

votes
0

answer
45

Views

Logging to email sink with Serilog

I have an aspnet core app and I'm trying to configure serilog to send me emails, with no luck. I have this configuration: Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() .MinimumLevel.Override('Microsoft', LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.File('1.log', LogE...
Evgeni
1

votes
0

answer
17

Views

Serilog's :l specifier is not working for the file sink

I am trying to provide a template for our old logging schema which looks like this: '{ClassicTimestamp:l}\t{ProductName:l}\t{ProductVersion:l}\t-1\t{LogLevelDigit}\t{LogLevelLetter:l}\t{Message:lj}%R%{ClassicException}\t{ProcessId}\t{ThreadId}{NewLine}' The ':l' is supposed to remove the quotes arou...
S. Mense
1

votes
0

answer
31

Views

ASP.Net WebAPI and logging with Serilog

I want to use Serilog in my WebApi project in order to log user actions, and exceptions. All the logs would be push in ElasticSearch. I also want to log from some custom library dependencies. In order to not have different references of serilog in my dependencies and my webApi project, I have been...
Dypso
1

votes
1

answer
54

Views

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

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 _logger; public MyClass(Microsoft.Extensions.Logging.ILogger logger) { _log...
Julian
1

votes
0

answer
15

Views

Configure multiple emails for Serilog.Email sink based on log level

In my asp.net core 2.2 project (C#), I want serilog to use different sinks depending on the log level. For example, for every level below warning I want to write to a sql database. For Warning I want to send email to [email protected] and for error and above I want to send an email to [email protected]
Owen
1

votes
1

answer
18

Views

Is there a ASP.NET Core 2 serilog sink for ActiveMq

I am working on a project and i need a Serilog sink for ActiveMq. I was not able to find this specific sink for ASP.NET Core 2. I need information does this sink already exists or do i need to create my implementation.
Marko Pavlovic
0

votes
0

answer
6

Views

Docker-compose not reading the environment variables to write logs to Elasticsearch

I am setting up docker-compose.yml file to read the environment variables for the docker image. I have serilog.sinks.elasticsearch nuget package referenced in my host project. If I run the project in Visual Studio with appsettings.json, it reads the settings and sends to logs to Elasticsearch but no...
Kabali

View additional questions