This repository contains the sources for the client-side components of the LogFlake product suite for applications logs and performance collection for .NET applications.
NuGet Package Name | Version | Downloads |
---|---|---|
LogFlake.Client.NetCore |
- Retrieve your application-key from Application Settings in LogFlake UI;
- Add in your
secrets.json
file the following section:
"LogFlake": {
"AppId": "application-key",
"Endpoint": "https://logflake-instance-here" // optional, if missing uses production endpoint
}
- ℹ️ Optional: Implement and register as a Singleton the interface
IVersionService
; - In your
Program.cs
files, register the LogFlake-related services:
// configuration is an instance of IConfiguration
services.AddLogFlake(configuration);
ℹ️ If you registered a custom implementation
IVersionService
; your registration must come before LogFlake services registration:
services.AddSingleton<IVersionService, MyVersionService>();
// configuration is an instance of IConfiguration
services.AddLogFlake(configuration);
- In your services, simply require
ILogFlakeService
as a dependency;
public class SimpleService : ISimpleService
{
private readonly ILogFlakeService _logFlakeService;
public SimpleService(ILogFlakeService logFlakeService)
{
_logFlakeService = logFlakeService ?? throw new ArgumentNullException(nameof(logFlakeService));
}
}
- Use it in your service
// SimpleService.cs
public void MyMethod()
{
try
{
doSomething();
_logFlakeService.WriteLog(LogLevels.INFO, "Hello World", "correlation");
}
catch (MeaningfulException ex)
{
_logFlakeService.WriteException(ex, "correlation");
}
}