AppCenter to AppInsights migration. (#562)
* Remove AppCenter usage and libraries. * Remove redundant pacakges and add the app insights sink. * Diagnostic id support and manipulating telemetries. * Handling of appdomain unhandled exceptions. * Remove unused package identity package from mail project. * Fixing printing.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Serilog;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
using Serilog.Exceptions;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Services.Misc;
|
||||
|
||||
namespace Wino.Services
|
||||
{
|
||||
@@ -9,10 +11,15 @@ namespace Wino.Services
|
||||
{
|
||||
private readonly LoggingLevelSwitch _levelSwitch = new LoggingLevelSwitch();
|
||||
private readonly IPreferencesService _preferencesService;
|
||||
private readonly IApplicationConfiguration _applicationConfiguration;
|
||||
private readonly TelemetryConfiguration _telemetryConfiguration;
|
||||
|
||||
public LogInitializer(IPreferencesService preferencesService)
|
||||
public LogInitializer(IPreferencesService preferencesService, IApplicationConfiguration applicationConfiguration)
|
||||
{
|
||||
_preferencesService = preferencesService;
|
||||
_applicationConfiguration = applicationConfiguration;
|
||||
|
||||
_telemetryConfiguration = new TelemetryConfiguration(applicationConfiguration.ApplicationInsightsInstrumentationKey);
|
||||
|
||||
RefreshLoggingLevel();
|
||||
}
|
||||
@@ -28,10 +35,13 @@ namespace Wino.Services
|
||||
|
||||
public void SetupLogger(string fullLogFilePath)
|
||||
{
|
||||
var insightsTelemetryConverter = new WinoTelemetryConverter(_preferencesService.DiagnosticId);
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.ControlledBy(_levelSwitch)
|
||||
.WriteTo.File(fullLogFilePath, retainedFileCountLimit: 3, rollOnFileSizeLimit: true, rollingInterval: RollingInterval.Day)
|
||||
.WriteTo.Debug()
|
||||
.WriteTo.ApplicationInsights(_telemetryConfiguration, insightsTelemetryConverter, restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error)
|
||||
.Enrich.FromLogContext()
|
||||
.Enrich.WithExceptionDetails()
|
||||
.CreateLogger();
|
||||
|
||||
Reference in New Issue
Block a user