serilog

Serilog not working with Elasticsearch

﹥>﹥吖頭↗ 提交于 2020-01-14 03:47:26
问题 I have installed Elasticsearch locally on my Windows 7 machine. It is working properly and I can query it using postman. Using Postman, I have also created an index called cmstest. This has a table called zdsf. If I get the mapping (http://localhost:9200/cmstest/_mapping) for this index I get the following: I can post entries to this table as well using Postman. Now, I am trying to use Serilog from my .NET 4.5 application to log to this localhost instance of Elasticsearch.But nothing seems to

Serilog in Windows-Service not writing to logfile

ぐ巨炮叔叔 提交于 2020-01-13 07:32:09
问题 I am using Serilog within an TopShelf Service, logging to the console and a rolling file. When running the service in a console my messages are written to the logfile, but when I install the service and run it no logging occurs. Is there anything special I need to configure? The file is written to the binaries folder under ".\logs\log-{date}.txt". Best regards Gope 回答1: I had a very similar issue. In my case the problem was with relative paths. I just had to specify absolute path. Now it

Serilog in Windows-Service not writing to logfile

不问归期 提交于 2020-01-13 07:32:06
问题 I am using Serilog within an TopShelf Service, logging to the console and a rolling file. When running the service in a console my messages are written to the logfile, but when I install the service and run it no logging occurs. Is there anything special I need to configure? The file is written to the binaries folder under ".\logs\log-{date}.txt". Best regards Gope 回答1: I had a very similar issue. In my case the problem was with relative paths. I just had to specify absolute path. Now it

Configuring Serilog RollingFile with appsettings.json

妖精的绣舞 提交于 2020-01-10 17:59:33
问题 I'm trying to configure Serilog for a .NET Core project. Here's what I have in my appsettings.json : "Serilog": { "MinimumLevel": "Verbose", "Enrich": ["FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId"], "WriteTo": [ { "Name": "RollingFile", "Args": { "pathFormat": "C:/Logfiles/testapp/log-{Date}.json", "textFormatter": "JsonFormatter", "fileSizeLimitBytes": 2147483648, "retainedFileCountLimit": 5 } } ] } The problem I see is that JsonFormatter is not picked up, and instead

.Net Core 3: Serilog don't log custom logs

≡放荡痞女 提交于 2020-01-06 15:22:05
问题 I have a web .NET Core 3 application using Serilog. If I filter the technical logs from MS namespaces, all logs disapear, event custom one. What I did I configure Serilog in Main.cs like this: public static int Main(string[] args) { var currentEnv = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($

What namespace am I missing for Serilog?

别说谁变了你拦得住时间么 提交于 2020-01-06 06:25:25
问题 What namspace and I missing for Serilog? I am able to use LoggerConfiguration() in my C# code with various Serilog Sinks but my compiler is complaining about the specification of my use of ".WriteTo.File". I am confused because I have ben able to use this specification in another demo solution. I wonder if there is some sort of Assembly I need to add as a reference. I have run "Install-Package Serilog.Sinks.File" from the "Package Manager Console" but that did not seem to have any effect or

What namespace am I missing for Serilog?

假装没事ソ 提交于 2020-01-06 06:25:05
问题 What namspace and I missing for Serilog? I am able to use LoggerConfiguration() in my C# code with various Serilog Sinks but my compiler is complaining about the specification of my use of ".WriteTo.File". I am confused because I have ben able to use this specification in another demo solution. I wonder if there is some sort of Assembly I need to add as a reference. I have run "Install-Package Serilog.Sinks.File" from the "Package Manager Console" but that did not seem to have any effect or

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

不羁岁月 提交于 2020-01-05 03:56:08
问题 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 )? 回答1: One way of doing this is with properties. But the configuration for enrichment properties has a caveat that it's a top level configuration and not an enrichment configuration: { "Serilog": { "Using": [ "Serilog", "Serilog

serilog to log only debug, error and warning logs but not information

半城伤御伤魂 提交于 2020-01-05 01:01:30
问题 I have an application with serilog configured for logging. I have a checkbox in my application, only on clicking that checkbox button it should log all information log else only Error and Warning log should be logged. In debug mode how to log only Debug, error and warning log when the button is unchecked. I have been trying to do this since 2 days. I have tried all the ways suggested in google/stackoverflow using .MinimumLevel.Debug() / restrictedToMinimumLevel: LogEventLevel.Debug it did not

.net Core and Serilog Email sink - json config

◇◆丶佛笑我妖孽 提交于 2020-01-04 03:19:11
问题 I'm using .net Core 2.0 and Serilog Email sink. I have problem to configure email sink with appsettings.json . The same configuration from program.cs is working while one from appsetting.json isn't. 回答1: The settings system ( ReadFrom.Configuration() ) really only does try to call methods and extension methods that it can discover and pass arguments provided from the configuration file . Unfortunately, it only supports basic types for the time being (convertible to/from string and a few more