Questions tagged [serilog]

1

votes
1

answer
19

Views

Persisting EventType with Serilog

I'm having trouble getting the EventType feature working in Serilog, as blogged about here. I am using the following Nuget packages: Serilog 2.8 Serilog.Settings.Configuration 3.0.1 Serilog.Sinks.File 4.0.0 Serilog.Sinks.MSSqlServer 5.1.2 First up, I created an EventTypeEnricher: public class Eve...
onefootswill
1

votes
1

answer
50

Views

Serilog logs to console but not to file

I have the below logger configuration and associated classes as below. The expected log messages are below: 2019-03-06 19:49:56.417 +05:30 [INFORMATION] [Main] Start 2019-03-06 19:49:56.435 +05:30 [INFORMATION] [Test1] Test1 logg I see both the log messages in console. But I see only the first log i...
sunil_mlec
0

votes
0

answer
3

Views

How do we extract Serilog .ForContext() objects logged to Elasticsearch, using ElasticClient (NEST)?

We are looking to better centralize, structure and search our logs using the ELK stack. We are currently logging to a database table, and we have an EventLog POCO that captures the fields required to populate those rows. Our first stab at getting this data into Elasticsearch was to simply log the ev...
lesscode
1

votes
1

answer
619

Views

Logentries + Xamarin = how?

The main question is: how to integrate Logentries in a Xamarin-based mobile app? Below two ways are taken into consideration: Serilog and log4net. Logentries supports Android, iOS, WP natively but not when those APIs are proxified using Xamarin. Serilog is an elegant C# wrapper around Logentries API...
Ivan
0

votes
0

answer
3

Views

What's the recommended way to write Serilog logs to Amazon S3?

I'm looking to use Serilog to write structured log data to an Amazon S3 bucket, then analyze using Databricks. I assumed there would be an S3 sink for Serilog but I found I was wrong. I think perhaps using the File sink along with something else might be the ticket, but I'm unsure what that might...
Clarke
1

votes
1

answer
122

Views

Serilog omitting base class properties on event serialization

I am serializing events with Serilog, this events can be sent from a wide arrange of services that extend a base abstract class that contains the essential information for any event, and the child classes add all needed specific event information. The problem is that in the log only the child class...
evilpilaf
1

votes
1

answer
135

Views

Sending PowerShell exceptions to Serilog

This questions is in regards to how to log a PowerShell exception in Serilog so that it's interpreted as a fist-class property and not a large string. I have a few issues: To get the full exception information I need to expand the properties of an ErrorRecord Serilog can't interpret an expanded Erro...
Blair Paine
1

votes
1

answer
466

Views

Serilog “Maximum destructuring depth reached”

I've enabled SeriLog (latest version) Self-Logging and am seeing hundreds of messages that say Maximum destructuring depth reached No idea what that means and whether it's a problem I need to worry about or not. Does anyone know what triggers this message and whether I'm doing something wrong?
Mr. T
1

votes
1

answer
671

Views

How to set the rolling file name to be unique by process ID

I am trying to have unique name on the log for each one of the processes running at the same time on a machine. I tried to set the pathFormat in the app.config to something similar to That didn't work. Any idea? I can't find anything in the documentation. Being able to write the output from multi...
abx78
1

votes
1

answer
76

Views

Serilog writing to undetermined number of log files

I have a bunch of archives, each contains thousands of files to be processed. I want to write one log file as summary, one containing errors if any, and finally, for each archive, a separate log file with all entries processed. The first two can be configured with WriteTo and Filters. But I don't...
Whoever
1

votes
2

answer
731

Views

basedir in appsettings.json in asp.net core

I started my new project in ASP.NET Core and I have a question. I have 2 loggers: a) nLog, that have it's config in nlog.config file b) serilog, that have it's config in appsettings.json At this moment, I have 2 locations to store logs: fileName='${basedir}/logs/EPR/nlog-all-${shortdate}.log - nL...
zchpit
1

votes
1

answer
456

Views

what is difference between Serilog.Sinks.File and Serilog.Extensions.Logging.File?

what is difference between Serilog.Sinks.File and Serilog.Extensions.Logging.File packages in asp.net core? When I tried to implement logging in asp.net core project with Serilog I found a quick example here which used Serilog.Sinks.File. When I tried to implement the same in my project,the logger f...
Mahesh Gupta
1

votes
1

answer
1.2k

Views

Trying to Configure Serilog Email sink with appsettings.json to work with Gmail

In in a POC I got the Smtp client to send emails through Gmail, so I know my information regarding connecting to Gmail's SMTP server is correct. I am now trying to configure Serilog through appsettings.json to send my log entries through Gmail. I need to be able to configure it different for diffe...
Timm Hagen
1

votes
2

answer
365

Views

Serilog not getting application events, only coded logger events

I set up my application to use Serilog as the logging mechanism. And I do in fact get log files and can view them on Seq. Initially I was getting the application events logged, but for some reason I am no longer getting them. See the images below. In the first image I am getting application events....
dinotom
1

votes
2

answer
473

Views

Serilog SelfLog to File Error

I need to enable self log of seri logger to text file. My configuration are follows; __serilogLogger = new LoggerConfiguration() .Enrich.WithProperty('ApplicationIPv4', _ipv4) .Enrich.WithProperty('ApplicationIPv6', _ipv6) .WriteTo.MSSqlServer(connectionString, tableName /*, columnOptions: columnOpt...
Akhil
1

votes
1

answer
459

Views

Serilog - MinimumLoggingLevel Information shows every request in log - is that normal?

ok, we are using Serilog in our web app and having it post to SEQ. (The site is a mix of classic ASP and .NET, but we only have Serilog calls in .NET) // create the logger Log.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(_levelSwitch) .WriteTo.Seq(seqIp) .CreateLogger(); When I have...
Beau D'Amore
1

votes
2

answer
152

Views

Get rid of typeParam Exception when defining LoggerMessage

I´m using serilog as a LoggingProvider in my ASP.NET Core WebApp and I want to use the LoggerMessage-features from Microsoft.Extensions.Logging.Abstractions. My logs are in JSON-format. If I want to log an object with Serilog I have the possibility to either log a simple .ToString() of the object o...
Joshit
1

votes
1

answer
94

Views

SQL Server XQuery Syntax Error

I'm using Serilog Sinks for SQLServer, and following DB schema and XQuery Syntax using this link. However when I run the following query in Navicat, I get error. Here's the query: SELECT Properties.value('(/properties/property[@key='contact']/structure[@type='Contact']/property[@key='ContactId'])[1...
Azaz ul Haq
0

votes
0

answer
8

Views

Microsoft Access-friendly Serilog sink

I am using SEQ, file and JSON as a Serilog sinks Log.Logger = new LoggerConfiguration() .Enrich.With(new ThreadIdEnricher()) //.Enrich.FromLogContext() .WriteTo.RollingFile(@'C:\QRT\Logs\QRT-LOG.txt', LogEventLevel.Information) .WriteTo.Seq('http://localhost:5341') .WriteTo.Console(restrictedToMinim...
Ed Landau
1

votes
1

answer
398

Views

Use Serilog with Azure Log Stream

I've been researching about how to use Serilog to write to Azure log stream. I found a few answers here too; for example, one answer was suggesting to log to a file in a specific folder (home\LogFiles\http\...), but it doesn't seem to be working for me. I tried using Trace and Debug sinks, but I cou...
Farzad
1

votes
1

answer
442

Views

Log structured data to Azure Storage table by Serilog store all object in RenderedMessage, I want column for each field in class

I write below code to log/store logs with an objects to Azure Table Storage by using SeriLog, But I got the object stored in 'RenderedMessage' column (in azure table) or 'Data' column, While I need to store each field/property in the class to a separated column in the Table storage. Please see below...
Bashar Abu Shamaa
1

votes
1

answer
87

Views

Is it possible to configure a format provider for the File sink using JSON configuration?

In the documentation for the Serilog.Sinks.File a JSON formatter is used: // Install-Package Serilog.Formatting.Compact .WriteTo.File(new CompactJsonFormatter(), 'log.txt') Is it possible to do the same using JSON configuration?
Paulo Morgado
1

votes
1

answer
166

Views

Is force logging available in Microsoft.Extensions.Logging

I have ASP.NET Core application. I am using Microsoft.Extensions.Logging.ILogger interface with Serilog logging provider. In production environment, the log level is set to Error. So anything below Error loglevel will not get logged. Is there Force logging available in Microsoft.Extensions.Logging,...
LP13
1

votes
1

answer
234

Views

Custom Logger Provider being excluded by Serilog

Serilog works great, but I noticed it seems to exclude any custom logger providers I setup. When I have UseSerilog() in my Startup, my CustomProvider never gets created (CreateLogger never gets called). Is it possible to still use custom providers with Serilog? //class Program, Main Method WebHost....
johnluke.laue
1

votes
1

answer
344

Views

Net Core 2 Serilog inject from Console App to Webhost

I would like to know how to manage and best way to bring Serilog instance from a console app to a StartUp class that configures a webhost. Scenario: I ve got a Main class from a console app where I configure a logger (serilog). Namespace 1 static void Main(string[] args) { DateTime Date = new DateT...
Sam
1

votes
1

answer
61

Views

Can Serilog return the value of resulting action rather than the data type?

I have Serilog in a .net core 2.1 web API using the Serilog.AspNetCore package. When an action gets called the incoming parameters are logged: [INF] Executing action method WebApi.Controllers.ValuesController.Get (WebApi) with arguments (['4']) - Validation state: 'Valid' But when the action is done...
Sailing Judo
1

votes
2

answer
124

Views

Unit Test - How to test a `void` method that just inserts a log message (Serilog)

I need to test a method of type void, it just inserts a message on my LOG variable using a LOG framework (Serilog). See the implementation example: public class MyClass { public MyClass(ILogger logger) { this.logger = logger; } private readonly ILogger logger; //...Anothers methods... public void Lo...
Igor
1

votes
1

answer
273

Views

Serilog MSSQL Sink doesn't write logs to database

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 opti...
djSmart
1

votes
2

answer
391

Views

Adding Serilog ILogger to a static class

I'd like to add a Serilog Log to a static class in my program like this (DataHelper is the class name): private readonly ILogger _log = Log.ForContext(); But this leads to the error message: static types cannot be used as type arguments Which makes sense. So how do I inject the logger (which is wor...
Disasterkid
1

votes
1

answer
65

Views

Create a new file with an updated suffix every time a new Logger is created with Serilog

I would like to have Serilog write to a new file with an incremented suffix every time a new Logger is created. For example: log_001.txt log_002.txt Basically, I want the behavior posted by the OP on this github issue: https://github.com/serilog/serilog-sinks-rollingfile/issues/9 I want was the OP w...
johnluke.laue
1

votes
2

answer
59

Views

Serilog in program class

I am trying to log with Serilog in an ASP.NET Core application's Program.cs class. My current setup is as follows: public class Program { public static void Main(string[] args) { DoStuff(); CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args)...
Harry Stuart
1

votes
0

answer
15

Views

Iterate through all sinks and enrichers registered in Serilog

How can I iterate through all sinks (ILogEventSink objects) and enrichers (ILogEventEnricher objects) registered in Serilog? I'm using Serilog.AspNetCore. Thanks.
user3392683
1

votes
0

answer
4

Views

Iterate through all sinks registered in Serilog

How can I iterate through all sinks (ILogEventSink objects) registered in Serilog? I'm using Serilog.AspNetCore.
user3392683
1

votes
2

answer
1.1k

Views

DI ILogger with Serilog on Webapi 2 running Asp.Net Core 2

I am trying to integrate Serilog to my WebApi 2 with Asp.Net Core 2 (With MSSQLServer integration). I have added the nuget packages and then added the following to my public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) var log = new LoggerConf...
Matthew Flynn
1

votes
1

answer
1.1k

Views

Using Serilog with .Net core and App Insights

I have used App insights directly for application logging before and I have seen that .Net core platform also creates trace events that goes to App insights. In a new .Net core API application, I'd like to use Serilog for application logging and App Insight for storing and visualizing the log event...
frosty
0

votes
0

answer
3

Views

Serilog writes the logs twice

I'm using Serilog with Elasticsearch sink with the configurations like this: Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .MinimumLevel.Override('Microsoft', LogEventLevel.Verbose) .Enrich.FromLogContext() .Enrich.WithExceptionDetails() .Enrich.WithProperty('Application', 'abc') .E...
mok
1

votes
1

answer
604

Views

How to log a message correlation Id with ServiceStack.Logging ILog?

I'm very satisfied with the current logging solution I have in place right now, which is the ServiceStack Interface being implemented by NLOG. The NLOG targets I am using are as follows: xsi:type='Console' xsi:type='Debugger' xsi:type='File' xsi:type='Seq' of particular importance is Seq which is a...
Stephen Patten
1

votes
1

answer
94

Views

Is it possible to check if any errors has been logged to a `ILogger` in Serilog?

Is it possible to check if any errors has been logged to a ILogger in Serilog? var log = new LoggerConfiguration().CreateLogger(); SomeAlgorithm(log); // How can I check if an error was logged?
Magnus Lindhe
0

votes
0

answer
3

Views

Serilog, Unity and WebApi - initial request hangs with An asynchronous module or handler completed while an asynchronous operation was still pending

I'm trying to use Serilog, resolved with Unity in a WebApi project but am having an unusual issue. I'm resolving the logger as follows from a method that is called on Application_Start: container.RegisterType(new ContainerControlledLifetimeManager(), new InjectionFactory((ctr, type, name) => { ILogg...
DavidWainwright
1

votes
1

answer
1.4k

Views

Unable to use Serilog in Controller in asp.net 5

How can I use Serilog from Controller itself? I have added this in my Configure method in Startup class : var serilog = new Serilog.LoggerConfiguration().MinimumLevel.Debug().WriteTo.File('C:/Temp/log.txt'); logFact.AddSerilog(serilog); I also tried something like this: public PeopleController(ILogg...
zoranpro

View additional questions