mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 02:39:29 +08:00
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
// Licensed under the Apache License, Version 2.0 (the "License").
|
|
// You may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
|
|
// Copyright (c) 2019 Gui.H
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Serilog;
|
|
using FastTunnel.Core.Client.Extensions;
|
|
using Serilog.Events;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using FastTunnel.Core.Config;
|
|
|
|
namespace FastTunnel.Client;
|
|
|
|
class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
Log.Logger = new LoggerConfiguration()
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
|
.Enrich.FromLogContext()
|
|
.WriteTo.Console().WriteTo.File("Logs/log-.log", rollingInterval: RollingInterval.Day)
|
|
.CreateBootstrapLogger();
|
|
|
|
try
|
|
{
|
|
CreateHostBuilder(args).Build().Run();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "致命异常");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.UseSerilog((context, services, loggerConfiguration) =>
|
|
{
|
|
loggerConfiguration.ReadFrom.Configuration(context.Configuration)
|
|
.ReadFrom.Services(services)
|
|
.Enrich.FromLogContext()
|
|
.WriteTo.Console();
|
|
})
|
|
.UseWindowsService()
|
|
.ConfigureServices((hostContext, services) =>
|
|
{
|
|
// -------------------FastTunnel START------------------
|
|
services.AddFastTunnelClient(hostContext.Configuration.GetSection("FastTunnel"));
|
|
// -------------------FastTunnel EDN--------------------
|
|
});
|
|
}
|