LANCommander/LANCommander.Server/Logging/LoggingHubTarget.cs
2024-08-28 20:33:59 -05:00

37 lines
No EOL
881 B
C#

/*
using NLog;
using NLog.Config;
using NLog.Targets;
namespace LANCommander.Logging
{
[Target("LoggingHub")]
public class LoggingHubTarget : AsyncTaskTarget
{
private LoggingHubConnection? Connection;
[RequiredParameter]
public string HubUrl { get; set; }
protected override void InitializeTarget()
{
Connection = new LoggingHubConnection(HubUrl);
}
protected override async Task WriteAsyncTask(LogEventInfo logEvent, CancellationToken token)
{
if (Connection != null)
await Connection.Log(Layout.Render(logEvent));
}
protected override async void CloseTarget()
{
if (Connection != null)
{
await Connection.DisposeAsync();
Connection = null;
}
}
}
}
*/