- ABP Framework version: v7.2.2
- UI Type: Angular
- Database System: EF Core (SQL Server)
-
- Auth Server Separated (for Angular)**: yes
Hey Guys,
We want to use the serilog sinks to log what ever issue happens inside the Application layer of the microservices. However I added the configuration for the sinks and when I throw an issue in the Application layer it is never picked up in the logs.
I have this configuration in the Program.cs file in the HttpApi.Host.
On the file it only writes what I have in the line 35, besides that It never gets an error.
This is how I am throwing an error and logging it using ILogger in the AppService under the project Application:
This is my file:
What else should I add to the configuration to make it work?
Let me know if I can provide more information
Thanks!
11 Answer(s)
-
0
hi
Each website has its log configuration. They are usually written to the
Logs.txt
. If you want all website logs written to a single file. You can configure a shared log file. -
0
hi
Each website has its log configuration. They are usually written to the
Logs.txt
.
If you want all website logs written to a single file. You can configure a shared log file.Hi Maliming actually what I need is to send them via email with send grid and also record them in the application insight, however I am doing a proof of concept. And what I found in this test is that it doesn't write to the log file that I specified. However with what you mentioned could be a reason on why it is not writting to the file I mention.
How can I achieve to send the error logs to the email? I tried using
.WriteTo.Email( fromEmail: "thisisanexample@example.com", toEmail: "cijal75666@minhlun.com", mailServer: "smtp.sendgrid.net", restrictedToMinimumLevel: LogEventLevel.Error )
but it doesnt work, that's why I was checking if the file log worked. but it didnt...
-
0
hi
but it doesnt work, that's why I was checking if the file log worked. but it didnt...
You can test your mail sender configuration via https://github.com/abpframework/abp-samples/tree/master/EmailSendDemo https://github.com/serilog/serilog-sinks-email/blob/dev/src/Serilog.Sinks.Email/Sinks/Email/MailKitEmailTransport.cs#L24-L37
-
0
hi
but it doesnt work, that's why I was checking if the file log worked. but it didnt...
You can test your mail sender configuration via https://github.com/abpframework/abp-samples/tree/master/EmailSendDemo https://github.com/serilog/serilog-sinks-email/blob/dev/src/Serilog.Sinks.Email/Sinks/Email/MailKitEmailTransport.cs#L24-L37
Hi Maliming thanks for the answer, I don't require to do any other configuration in the Program file?
-
0
hi
You need to make sure your email sender configuration is correct.
Then use
WriteTo.Email
in all projects that want to use email to output logs.https://github.com/serilog/serilog-sinks-email
-
0
hi
You need to make sure your email sender configuration is correct.
Then use
WriteTo.Email
in all projects that want to use email to output logs.https://github.com/serilog/serilog-sinks-email
Hi Maliming,
Thanks I'll review it as soon as possible and will ask if I got any other question. Thanks again!
-
0
sure. no problem. : )
-
0
sure. no problem. : )
Hi Maliming, we got a project were we are sure the emailing is working, however I still can't make the serilog send an email with the error, is there any demo for this with ABP? I couldn't find any information about this.
Also when adding the Sink for file/console it is only logging the httpapihist errors, not the one in the other layers, how can we implement so we see the erros from all the layers ? As I am sure if I fix the email issue I will only get the errors from the httpapihost layer
-
0
hi
we got a project were we are sure the emailing is working, however I still can't make the serilog send an email with the error, is there any demo for this with ABP? I couldn't find any information about this.
Can you share the email SMTP info with me? I will test it on my local. liming.ma@volosoft.com
Also when adding the Sink for file/console it is only logging the httpapihist errors, not the one in the other layers, how can we implement so we see the erros from all the layers ? As I am sure if I fix the email issue I will only get the errors from the httpapihost layer
Like I said. Each website has its log configuration. You need to configure them to output logs to a data source.
-
0
I was finally able to make it work. For everyone who wonders, you'll need to add the configuration in the "Shared.Hosting" project. under the class SerilogConfigurationHelper. There I used the nuget for SerilogSinksSendgrid and done
-
0
Thanks abpnewtonvisionco