feat: add file logging
This commit is contained in:
parent
57fe6f9d8d
commit
8790b1a3bf
3 changed files with 10 additions and 1 deletions
|
@ -189,7 +189,7 @@ public abstract class AuthSession : TcpSession
|
|||
buffer[3],
|
||||
Id, this);
|
||||
Parallel.Invoke(() => _mediator.Send(rawPacket));
|
||||
_logger.LogInformation("Connection from: {@RemoteEndpoint}", Socket.RemoteEndPoint);
|
||||
_logger.LogInformation("Connection from: {@RemoteEndpoint}", Socket.RemoteEndPoint?.ToString());
|
||||
base.OnReceived(decryptedBuffer.ToArray(), offset, decryptedBuffer.Length);
|
||||
}
|
||||
catch (CryptographicException ex)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Net;
|
||||
using System.Reflection;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -9,6 +10,9 @@ using Server;
|
|||
Console.WriteLine(BitConverter.IsLittleEndian);
|
||||
|
||||
var builder = Host.CreateApplicationBuilder();
|
||||
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||
builder.Logging.AddFile("Logs/Server-{Date}.log", LogLevel.Trace);
|
||||
builder.Logging.AddFile("Logs/Server-{Date}.json.log", isJson: true, minimumLevel: LogLevel.Trace);
|
||||
builder.Services.AddLogging();
|
||||
builder.Services.AddSingleton<PacketDistributorService>();
|
||||
builder.Services.AddHostedService<PacketDistributorService>(provider =>
|
||||
|
|
|
@ -23,11 +23,16 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
|
||||
<PackageReference Include="NetCoreServer" Version="7.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue