From 9b22249a899df863674476c4acdaba5cd3703e68 Mon Sep 17 00:00:00 2001 From: Vijay Uppu <913468@dadeschools.net> Date: Tue, 23 Jan 2024 15:21:59 -0500 Subject: [PATCH] added log changes to store in a file --- .../DamageAssesment.Api.Answers.csproj | 3 +++ DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs | 5 +++++ .../DamageAssesment.Api.Attachments.csproj | 3 +++ .../DamageAssesment.Api.Attachments/Program.cs | 7 ++++++- .../DamageAssesment.Api.DocuLinks.csproj | 3 +++ .../DamageAssesment.Api.DocuLinks/Program.cs | 6 +++++- .../DamageAssesment.Api.Employees.csproj | 3 +++ .../DamageAssesment.Api.Employees/Program.cs | 6 +++++- .../DamageAssesment.Api.Locations.csproj | 3 +++ .../DamageAssesment.Api.Locations/Program.cs | 6 +++++- .../DamageAssesment.Api.Questions.csproj | 3 +++ .../DamageAssesment.Api.Questions/Program.cs | 5 +++++ .../DamageAssesment.Api.Responses.csproj | 3 +++ .../DamageAssesment.Api.Responses/Program.cs | 6 +++++- .../DamageAssesment.Api.Surveys.csproj | 3 +++ DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs | 5 +++++ .../DamageAssesment.Api.UsersAccess.csproj | 3 +++ .../DamageAssesment.Api.UsersAccess/Program.cs | 5 +++++ 18 files changed, 73 insertions(+), 5 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj b/DamageAssesmentApi/DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj index 853990d..dedd1e3 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj @@ -19,7 +19,10 @@ + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs index 18759d5..b6fff90 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Program.cs @@ -31,6 +31,11 @@ builder.Services.AddAuthentication(item => ClockSkew = TimeSpan.Zero }; }); +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/answers-{Date}.txt"); // Specify the file path and format +}); // Add services to the container. builder.Services.AddControllers(); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj b/DamageAssesmentApi/DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj index 157cd85..9c7c5ce 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj @@ -27,7 +27,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs index 77c9e4b..0edec70 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Program.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Http.Features; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Tokens; using Microsoft.OpenApi.Models; using System.Reflection; @@ -15,7 +16,11 @@ builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); })); var authkey = builder.Configuration.GetValue("JwtSettings:securitykey"); - +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/attachments-{Date}.txt"); // Specify the file path and format +}); builder.Services.AddAuthentication(item => { item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; diff --git a/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/DamageAssesment.Api.DocuLinks.csproj b/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/DamageAssesment.Api.DocuLinks.csproj index 7058f27..02f042b 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/DamageAssesment.Api.DocuLinks.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/DamageAssesment.Api.DocuLinks.csproj @@ -25,7 +25,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Program.cs index 4e4a4e1..151961a 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Program.cs @@ -14,7 +14,11 @@ builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { })); // Add services to the container. var authkey = builder.Configuration.GetValue("JwtSettings:securitykey"); - +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/DocuLinks-{Date}.txt"); // Specify the file path and format +}); builder.Services.AddAuthentication(item => { item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj b/DamageAssesmentApi/DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj index cbaabfd..abee9bd 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj @@ -24,7 +24,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs index 071cc80..8d55b33 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Employees/Program.cs @@ -14,7 +14,11 @@ builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { })); // Add services to the container. var authkey = builder.Configuration.GetValue("JwtSettings:securitykey"); - +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/Employees-{Date}.txt"); // Specify the file path and format +}); builder.Services.AddAuthentication(item => { item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj b/DamageAssesmentApi/DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj index 60acab4..44aa434 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj @@ -25,7 +25,10 @@ + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs index ca9bb42..a7fd36e 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Locations/Program.cs @@ -14,7 +14,11 @@ builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { })); // Add services to the container. var authkey = builder.Configuration.GetValue("JwtSettings:securitykey"); - +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/Locations-{Date}.txt"); // Specify the file path and format +}); builder.Services.AddAuthentication(item => { item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj b/DamageAssesmentApi/DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj index 60acab4..44aa434 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj @@ -25,7 +25,10 @@ + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs index 9f704b8..104abba 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Questions/Program.cs @@ -12,6 +12,11 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); })); +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/Questions-{Date}.txt"); // Specify the file path and format +}); // Add services to the container. var authkey = builder.Configuration.GetValue("JwtSettings:securitykey"); builder.Services.AddAuthentication(item => diff --git a/DamageAssesmentApi/DamageAssesment.Api.Responses/DamageAssesment.Api.Responses.csproj b/DamageAssesmentApi/DamageAssesment.Api.Responses/DamageAssesment.Api.Responses.csproj index c9d3645..20d3949 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Responses/DamageAssesment.Api.Responses.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.Responses/DamageAssesment.Api.Responses.csproj @@ -30,8 +30,11 @@ + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.Responses/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Responses/Program.cs index 7f3473b..482475c 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Responses/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Responses/Program.cs @@ -19,7 +19,11 @@ const int intervalForCircuitBraker = 5; //5 seconds builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); })); - +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/Responses-{Date}.txt"); // Specify the file path and format +}); // Add services to the container. var authkey = builder.Configuration.GetValue("JwtSettings:securitykey"); builder.Services.AddAuthentication(item => diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Surveys.csproj b/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Surveys.csproj index 60acab4..44aa434 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Surveys.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Surveys.csproj @@ -25,7 +25,10 @@ + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs index a1cdac7..e0b0899 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs @@ -12,6 +12,11 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); })); +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/Surveys-{Date}.txt"); // Specify the file path and format +}); // Add services to the container. var authkey = builder.Configuration.GetValue("JwtSettings:securitykey"); builder.Services.AddAuthentication(item => diff --git a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj index ecde420..c97cb2f 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj +++ b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj @@ -24,8 +24,11 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Program.cs index be2170e..0e39fc0 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Program.cs @@ -21,6 +21,11 @@ builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); })); +builder.Services.AddLogging(builder => +{ + //builder.AddConsole(); // Optional: Add other providers if needed + builder.AddFile("logs/UserAccess-{Date}.txt"); // Specify the file path and format +}); // Add services to the container. var authkey = builder.Configuration.GetValue("JwtSettings:securitykey"); var mode = builder.Configuration.GetValue("ModeSettings:mode");