39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using Microsoft.ApplicationInsights.Channel;
|
|
|
|
namespace Core.Telemetry
|
|
{
|
|
public class DebugTelemetryChannel : InMemoryChannel, ITelemetryChannel
|
|
{
|
|
private readonly string _filePath;
|
|
public ITelemetryChannel _defaultChannel;
|
|
static HttpClient _client = new HttpClient();
|
|
|
|
public DebugTelemetryChannel(string filePath)
|
|
{
|
|
_client.BaseAddress = new Uri("http://localhost:5341");
|
|
_filePath = filePath;
|
|
}
|
|
public new void Send(ITelemetry telemetry)
|
|
{
|
|
var l = new SeqLogger(_client, "", "");
|
|
|
|
//await l.LogToSeq(
|
|
// "Bruger {UserId} loggede ind",
|
|
// "Debug",
|
|
// new Dictionary<string, object> { { "UserId", "12345" }, { "Counter", i++ } }
|
|
// );
|
|
|
|
|
|
if (telemetry is Microsoft.ApplicationInsights.DataContracts.TraceTelemetry trace)
|
|
{
|
|
var severity = trace.SeverityLevel;
|
|
Console.WriteLine($"Trace severity: {severity}, Message: {trace.Message}");
|
|
}
|
|
|
|
|
|
base.Send(telemetry);
|
|
var logEntry = $"{DateTime.UtcNow:u}|{telemetry.Context.Operation.Name}|{telemetry.Context.Operation.Id}";
|
|
//File.AppendAllText(_filePath, logEntry + Environment.NewLine);
|
|
}
|
|
}
|
|
}
|