From e7e092cadc7c08198a6c851982eda60f29bcd7f2 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Mon, 8 Jan 2024 18:40:52 -0600 Subject: [PATCH] Serilog --- .gitignore | 1 + src/WebStarter/Program.cs | 12 +++++++++- src/WebStarter/Properties/launchSettings.json | 2 +- src/WebStarter/WebStarter.csproj | 22 +++++++------------ 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 4e3f182a..cb5e824e 100644 --- a/.gitignore +++ b/.gitignore @@ -288,3 +288,4 @@ __pycache__/ *.bin /src/WebStarter/data/conversations XMLs +logs diff --git a/src/WebStarter/Program.cs b/src/WebStarter/Program.cs index 8c0634e1..9dd744c7 100644 --- a/src/WebStarter/Program.cs +++ b/src/WebStarter/Program.cs @@ -7,9 +7,18 @@ using BotSharp.Plugin.ChatHub; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; using System.Text; +using Serilog; var builder = WebApplication.CreateBuilder(args); +Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.Console() + .WriteTo.File("logs/log-.txt", rollingInterval: RollingInterval.Day) + .CreateLogger(); + +builder.Host.UseSerilog(Log.Logger); + builder.Services.AddScoped(); // Add bearer authentication builder.Services.AddAuthentication(options => @@ -40,7 +49,8 @@ builder.Services.AddCors(options => { options.AddPolicy("MyCorsPolicy", builder => builder.WithOrigins("http://localhost:5015", - "https://botsharp.scisharpstack.org") + "https://botsharp.scisharpstack.org", + "https://chat.scisharpstack.org") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); diff --git a/src/WebStarter/Properties/launchSettings.json b/src/WebStarter/Properties/launchSettings.json index 80a9cf62..8217c052 100644 --- a/src/WebStarter/Properties/launchSettings.json +++ b/src/WebStarter/Properties/launchSettings.json @@ -7,7 +7,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "dotnetRunMessages": true, - "applicationUrl": "http://localhost:5500" + "applicationUrl": "http://0.0.0.0:5500" }, "IIS Express": { "commandName": "IISExpress", diff --git a/src/WebStarter/WebStarter.csproj b/src/WebStarter/WebStarter.csproj index ab3e2566..3eb14e31 100644 --- a/src/WebStarter/WebStarter.csproj +++ b/src/WebStarter/WebStarter.csproj @@ -24,24 +24,18 @@ - - - + + + + - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - + + + +