From 18eb5d92e1f50c7610aa475fce7039c6c0acad44 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 8 Nov 2026 22:55:35 +0330 Subject: [PATCH] add using XLoggingService ... --- .gitignore | 1 + Startup.cs | 7 +++-- appsettings.json | 71 ++++++++++++++++++++++-------------------------- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/.gitignore b/.gitignore index 1e99217..dc69e18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # bin obj +Logs # Db/* diff --git a/Startup.cs b/Startup.cs index 41c804a..1c5ea71 100644 --- a/Startup.cs +++ b/Startup.cs @@ -42,7 +42,6 @@ namespace xApi public void ConfigureServices(IServiceCollection services) { - services.AddXLoggingService(Configuration); // // Register Validation Provider and all XCommons Module Services ... services.AddXCommons(Configuration); @@ -52,6 +51,10 @@ namespace xApi services.AddXAppConfiguration(Configuration); var appConfiguration = services.GetRegisteredService(); + // + // Register Logging Service ... + services.AddXLoggingService(Configuration); + // // Register Allowed Origins ... services.AddXCors(appConfiguration.AllowedOrigins); @@ -122,7 +125,7 @@ namespace xApi } public void Configure( - IApplicationBuilder app, + IApplicationBuilder app, IWebHostEnvironment env ) { diff --git a/appsettings.json b/appsettings.json index 764952f..e821c71 100644 --- a/appsettings.json +++ b/appsettings.json @@ -4,10 +4,7 @@ "DefaultLanguage": "fa-IR", "XPoweredValue": "SaherElmITCenter", "WelcomeMessage": "Welcome to xSaherElm Project's API", - "AllowedOrigins": [ - "http://saherelm.ir", - "https://saherelm.ir" - ], + "AllowedOrigins": ["http://saherelm.ir", "https://saherelm.ir"], "SwaggerConfiguration": { "Version": "v1.0", "Title": "xSaherElm API", @@ -180,45 +177,43 @@ "XPoweredValue": "SaherElmITCenter", "DefaultClientTimeout": -1 }, + "LoggingServiceConfiguration": { + "Enabled": true, + "MinimumLevel": "Information", + "Queue": { + "Enabled": true, + "Capacity": 10000, + "ShutdownTimeoutSeconds": 10 + }, + "File": { + "Enabled": true, + "Format": "Json", + "Directory": "./Logs", + "FileName": "xApi-.log", + "MinimumLevel": "Information", + "RetainedFileCountLimit": 30 + }, + "Database": { + "Enabled": false, + "TableName": "XLogs", + "AutoCreateTable": true, + "MinimumLevel": "Warning", + "Provider": "Microsoft.Data.Sqlite", + "ConnectionString": "Filename=./Db/XLogs.db" + }, + "Event": { + "Enabled": false, + "Sender": "xApi", + "MinimumLevel": "Error", + "Topic": "application-logs", + "Action": "ApplicationLogCreated" + } + }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" - }, - "XLogger": { - "Enabled": true, - "ApplicationName": "xApi", - "EnvironmentName": "Production", - "MinimumLevel": "Information", - "Queue": { - "Enabled": true, - "Capacity": 10000, - "ShutdownTimeoutSeconds": 10 - }, - "File": { - "Enabled": true, - "Directory": "./Logs", - "FileName": "xApi-.log", - "Format": "Json", - "MinimumLevel": "Information", - "RetainedFileCountLimit": 30 - }, - "Database": { - "Enabled": false, - "Provider": "Microsoft.Data.Sqlite", - "ConnectionString": "Filename=./Db/XLogs.db", - "TableName": "XLogs", - "AutoCreateTable": true, - "MinimumLevel": "Warning" - }, - "Event": { - "Enabled": false, - "Topic": "application-logs", - "Action": "ApplicationLogCreated", - "Sender": "xApi", - "MinimumLevel": "Error" - } } }, "AllowedHosts": "*"