Compare commits

..
8 Commits
Author SHA1 Message Date
saherelm 8c4402ba2b add config for cache ttl ... 2026-11-15 21:26:18 +03:30
saherelm 889d5b34f6 Fix Verification TTL to Minutes ... 2026-11-13 19:01:42 +03:30
saherelm d85314b05a cleaning configuration for bot ... 2026-11-13 13:49:30 +03:30
saherelm 18a9b4e7c7 update Bot Configurations ... 2026-11-11 23:42:45 +03:30
saherelm f013a46362 Add XBot Service Configurations in appSettings ... 2026-11-11 18:05:31 +03:30
saherelm 374c3258ef - .gitignore: +Logs
- Program.cs: Telemetry configuration
- Startup.cs: Request logging middleware
2026-11-09 12:53:05 +03:30
saherelm 18eb5d92e1 add using XLoggingService ... 2026-11-08 22:55:35 +03:30
saherelm c711cae78f last ... 2026-11-08 17:59:09 +03:30
5 changed files with 99 additions and 27 deletions
+1
View File
@@ -1,6 +1,7 @@
# #
bin bin
obj obj
Logs
# #
Db/* Db/*
+13 -3
View File
@@ -1,3 +1,4 @@
using xLoggingService.DI;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
@@ -10,11 +11,20 @@ namespace xApi
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
} }
public static IHostBuilder CreateHostBuilder(string[] args) => public static IHostBuilder CreateHostBuilder(string[] args)
Host.CreateDefaultBuilder(args) {
//
var result = Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
logging.AddXTelemetryLogger())
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}); })
.AddXTelemetry();
//
return result;
}
} }
} }
+24 -2
View File
@@ -6,6 +6,7 @@ using Newtonsoft.Json;
using xApi.Extensions; using xApi.Extensions;
using xHttpService.DI; using xHttpService.DI;
using System.Reflection; using System.Reflection;
using xLoggingService.DI;
using xCommons.Extensions; using xCommons.Extensions;
using xDataService.Models; using xDataService.Models;
using xIdentityService.DI; using xIdentityService.DI;
@@ -50,6 +51,10 @@ namespace xApi
services.AddXAppConfiguration(Configuration); services.AddXAppConfiguration(Configuration);
var appConfiguration = services.GetRegisteredService<XAppConfiguration>(); var appConfiguration = services.GetRegisteredService<XAppConfiguration>();
//
// Register Logging Service ...
services.AddXLoggingService(Configuration);
// //
// Register Allowed Origins ... // Register Allowed Origins ...
services.AddXCors(appConfiguration.AllowedOrigins); services.AddXCors(appConfiguration.AllowedOrigins);
@@ -119,14 +124,22 @@ namespace xApi
); );
} }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(
IApplicationBuilder app,
IWebHostEnvironment env
)
{ {
// //
if (env.IsDevelopment()) var isDevelopmentEnvironment = env.IsDevelopment();
if (isDevelopmentEnvironment)
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
//
// Setting Environment in App Confiuration ...
app.AddEnvironmentToXAppConfiguration(env.EnvironmentName);
// //
// Use Swagger Middleware ... // Use Swagger Middleware ...
app.UseXSwagger(); app.UseXSwagger();
@@ -141,6 +154,13 @@ namespace xApi
// //
app.UseRouting(); app.UseRouting();
//
// Using Request Logging ...
if (!isDevelopmentEnvironment)
{
app.UseXRequestLogger();
}
// //
// Enable Api Key Usage Logs ... // Enable Api Key Usage Logs ...
// app.UseXApiKeyUsage(); // app.UseXApiKeyUsage();
@@ -170,3 +190,5 @@ namespace xApi
} }
} }
} }
+40 -4
View File
@@ -4,10 +4,8 @@
"DefaultLanguage": "fa-IR", "DefaultLanguage": "fa-IR",
"XPoweredValue": "SaherElmITCenter", "XPoweredValue": "SaherElmITCenter",
"WelcomeMessage": "Welcome to xSaherElm Project's API", "WelcomeMessage": "Welcome to xSaherElm Project's API",
"AllowedOrigins": [ "AllowedOrigins": ["http://saherelm.ir", "https://saherelm.ir"],
"http://saherelm.ir", "DefaultCacheTtlMinutes": 10,
"https://saherelm.ir"
],
"SwaggerConfiguration": { "SwaggerConfiguration": {
"Version": "v1.0", "Version": "v1.0",
"Title": "xSaherElm API", "Title": "xSaherElm API",
@@ -180,6 +178,44 @@
"XPoweredValue": "SaherElmITCenter", "XPoweredValue": "SaherElmITCenter",
"DefaultClientTimeout": -1 "DefaultClientTimeout": -1
}, },
"BotServiceConfiguration": {
"VerificationCodeTTL": 5,
"DefaultClientTimeout": 3600,
"BaseRoute": "https://tapi.bale.ai",
"Token": "57317004:D2I9H0KWq2rTB44hHlZ7fOCa9oTgUU6RGIg"
},
"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": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
+6 -3
View File
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<!-- Runtime Definition --> <!-- Runtime Definition -->
<PropertyGroup> <PropertyGroup>
<Version>1.0.0</Version> <Version>1.0.0</Version>
@@ -22,16 +23,17 @@
<!-- Icon Handling --> <!-- Icon Handling -->
<ItemGroup> <ItemGroup>
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true" <None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true" PackagePath="\icon.png" />
PackagePath="\icon.png" />
</ItemGroup> </ItemGroup>
<!-- Local Dependencies --> <!-- Local Dependencies -->
<ItemGroup>
</ItemGroup>
<!-- Local Projects --> <!-- Local Projects -->
<ItemGroup> <ItemGroup>
<!-- All Modules Has Dependencies in xService -->
<ProjectReference Include="..\Modules\xServices\xServices.csproj" /> <ProjectReference Include="..\Modules\xServices\xServices.csproj" />
<ProjectReference Include="..\Modules\xLoggingService\xLoggingService.csproj" />
</ItemGroup> </ItemGroup>
<!-- Dependencies --> <!-- Dependencies -->
@@ -60,4 +62,5 @@
<Target Name="CreateRequiredFolder" AfterTargets="AfterPublish"> <Target Name="CreateRequiredFolder" AfterTargets="AfterPublish">
<MakeDir Directories="$(PublishDir)wwwroot" Condition="!Exists('$(PublishDir)wwwroot')" /> <MakeDir Directories="$(PublishDir)wwwroot" Condition="!Exists('$(PublishDir)wwwroot')" />
</Target> </Target>
</Project> </Project>