mirror of
https://github.com/raphaeIl/Novaria.git
synced 2025-12-13 15:04:36 +01:00
68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Serilog.Events;
|
|
using Serilog;
|
|
|
|
namespace Novaria
|
|
{
|
|
internal class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
Console.WriteLine(@"
|
|
|
|
|
|
|
|
_ _ ___ __ __ _ ____ ___ _
|
|
| \ | | / _ \\ \ / // \ | _ \ |_ _| / \
|
|
| \| || | | |\ \ / // _ \ | |_) | | | / _ \
|
|
| |\ || |_| | \ V // ___ \ | _ < | | / ___ \
|
|
|_| \_| \___/ \_//_/ \_\|_| \_\|___|/_/ \_\
|
|
|
|
|
|
|
|
|
|
");
|
|
var config = new ConfigurationBuilder()
|
|
.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)!)
|
|
.AddJsonFile("appsettings.json")
|
|
.AddJsonFile(
|
|
$"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json",
|
|
true
|
|
)
|
|
.AddJsonFile("appsettings.Local.json", true)
|
|
.Build();
|
|
|
|
{
|
|
var logFilePath = Path.Combine(
|
|
Path.GetDirectoryName(AppContext.BaseDirectory)!,
|
|
"logs",
|
|
"log.txt"
|
|
);
|
|
|
|
if (File.Exists(logFilePath))
|
|
{
|
|
var prevLogFilePath = Path.Combine(
|
|
Path.GetDirectoryName(logFilePath)!,
|
|
"log-prev.txt"
|
|
);
|
|
if (File.Exists(prevLogFilePath))
|
|
File.Delete(prevLogFilePath);
|
|
|
|
File.Move(logFilePath, prevLogFilePath);
|
|
}
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
.WriteTo.Console()
|
|
.WriteTo.File(
|
|
logFilePath,
|
|
restrictedToMinimumLevel: LogEventLevel.Verbose,
|
|
shared: true
|
|
)
|
|
.ReadFrom.Configuration(config)
|
|
.CreateBootstrapLogger();
|
|
}
|
|
|
|
GameServer.GameServer.Main(args);
|
|
}
|
|
}
|
|
} |