serilog-contrib / Serilog.Sinks.Logz.Io

Apache License 2.0
15 stars 11 forks source link

Logs are not appear on Logz.IO Dashboard #37

Closed NiveshShastriIdeavate closed 1 year ago

NiveshShastriIdeavate commented 1 year ago

Hello Team,

My application development logs are visible on the Logz.IO dashboard but in the case of Prod not. I have found one difference b/w both files below: (Additional XT text is there in the bookmark file)

issue

Please let me know how to fix this issue my API is deployed on Azure App Services that's why I am unable to delete files there.

Thank You.

mantasaudickas commented 1 year ago

Can you check library versions related to Serilog in the deployed application directory? This library depends on Serilog.Sinks.Http which is actually producing that file.

NiveshShastriIdeavate commented 1 year ago

Hello @mantasaudickas

I am using serilog.sinks.logz.io7.2.0 version. Serilog.Sinks.Http 8.0.0 issue 2

mantasaudickas commented 1 year ago

I see.. but here you see what is referenced, but not what is deployed :)

Have you tried to enable Serilog diagnostics like described here: https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics ?

NiveshShastriIdeavate commented 1 year ago

No, I didn't. Is it necessary for debugging?

mantasaudickas commented 1 year ago

Normally you can see if any internal errors are happening which helps to identify actual cause why logs are not sent to the server.

NiveshShastriIdeavate commented 1 year ago

Ok, I am adding Serilog.Debugging.SelfLog.Enable(msg => Debug.WriteLine(msg)); at startup then deploy.

But where I can check these logs?

mantasaudickas commented 1 year ago

I think you should use:

var file = File.CreateText(...);
Serilog.Debugging.SelfLog.Enable(TextWriter.Synchronized(file));

Where you can specify path and file path where these logs should be written.

Debug.WriteLine does not log in release mode and in order to write something to file you need to do additional stuff like: https://stackoverflow.com/questions/7926577/writing-c-sharp-debug-output-to-txt-file

NiveshShastriIdeavate commented 1 year ago

I found this logs inside file:

2023-05-05T08:35:52.0976470Z Received failed HTTP shipping result BadRequest: {"malformedLines":3,"oversizedLines":0,"successfulLines":97}
2023-05-05T08:35:54.5301179Z Received failed HTTP shipping result BadRequest: {"malformedLines":3,"oversizedLines":0,"successfulLines":97}
mantasaudickas commented 1 year ago

Maybe you can try to examine buffer file and try to identify which ones are malformed? Not sure how.. but maybe just by looking into you can find some special/invalid symbols used or smth..

NiveshShastriIdeavate commented 1 year ago

I found a log file(Date.txt) which is not looked a like valid JSON file.

Is there any way to delete old log files (like bookmark and logs(date).text files from code)?

mantasaudickas commented 1 year ago

Log files are deleted based on retention settings: https://github.com/serilog-contrib/Serilog.Sinks.Logz.Io/blob/master/src/Serilog.Sinks.Logz.Io/LogzioSinkConfigurationExtensions.cs#L145

Library does not provide any explicit support to delete files. You probably can use some methods from here: https://learn.microsoft.com/en-us/dotnet/api/system.io.file?view=net-8.0

But be aware - you might loose your logs. And I think it is better to investigate what caused these issues instead of simply deleting files.

Btw, whole file is not a valid JSON - only log entry (line) should be a valid json.

NiveshShastriIdeavate commented 1 year ago

Btw, whole file is not a valid JSON - only log entry (line) should be a valid json.

I found one entry that is not a valid JSON in the whole record.

Ohk, Thank you for the quick reply.