feat: refactor logging with OpenTelemetry integration

refactor: migrate XRequestLogger to xLoggingService
- Move Logging from xCommons to xLoggingService
- Add new XRequestLoggingMiddleware
- Integrate OpenTelemetry (v1.6.0)
- Apply logging across xAiApi, xAiMcpServer, xIds
- Update .gitignore for Logs folders

Breaking Changes:
- UseXRequestLogger now in xLoggingService.DI
- OpenTelemetry packages updated
This commit is contained in:
2026-11-09 12:54:16 +03:30
parent 708e2f8a4f
commit 01ea6d15c2
8 changed files with 238 additions and 6 deletions
@@ -0,0 +1,96 @@
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>گزارش تغییرات ۱۴۰۵/۰۸/۱۷ - v01 | xSaherelmWorkspace</title>
<style>
:root {--p:#173b78;--s:#2563eb;--bg:#f4f7fb;--l:#dbe3ef;--ok:#166534;--w:#b45309}
* {box-sizing:border-box}
body {margin:0;padding:24px;background:linear-gradient(135deg,#eef4ff,#f8fafc);color:#172033;font-family:Tahoma,"Segoe UI",sans-serif;line-height:1.9}
.wrap {max-width:1200px;margin:auto;background:#fff;border-radius:16px;box-shadow:0 12px 40px rgba(32,56,100,0.13)}
.hero {padding:36px;background:linear-gradient(135deg,var(--p),var(--s));color:#fff}
.hero h1 {margin:0 0 8px;font-size:2em}
.meta {display:flex;gap:24px;flex-wrap:wrap;padding:16px 30px;background:#f8fafc;border-bottom:1px solid var(--l);color:#53627a}
.meta strong {color:var(--p)}
main {padding:30px}
.section {margin-bottom:26px;padding:22px;background:var(--bg);border-right:5px solid var(--s);border-radius:10px}
.section h2 {margin:0 0 15px;color:var(--p);font-size:1.35em;border-bottom:1px solid var(--l);padding-bottom:8px}
table {width:100%;border-collapse:collapse;background:#fff;margin:12px 0}
th,td {text-align:right;vertical-align:top;padding:10px 12px;border-bottom:1px solid var(--l)}
th {background:var(--p);color:#fff}
code {direction:ltr;display:inline-block;background:#e7edf6;border-radius:4px;padding:2px 6px;font-family:Consolas,monospace;font-size:0.9em}
.badge {display:inline-block;padding:3px 8px;border-radius:4px;font-size:0.8em;font-weight:600}
.badge.added {background:#d1fae5;color:#065f46}
.badge.mod {background:#fef3c7;color:#92400e}
.badge.rm {background:#fee2e2;color:#991b1b}
.note,.warn,.ok {padding:12px 15px;border-radius:7px;margin:12px 0}
.note {background:#eff6ff;border-right:4px solid var(--s)}
.warn {background:#fff7ed;border-right:4px solid var(--w)}
.ok {background:#f0fdf4;border-right:4px solid var(--ok)}
ul {list-style:none;padding:0;margin:10px 0}
li {padding:6px 0;padding-right:20px}
footer {text-align:center;color:#68758a;padding:20px;border-top:1px solid var(--l)}
</style>
</head>
<body>
<div class="wrap">
<div class="hero"><h1>گزارش تغییرات</h1><p>سه شنبه ۱۷ آبان ۱۴۰۵ | 2026-11-09</p></div>
<div class="meta"><strong>نسخه:</strong> v01 | <strong>پروژه:</strong> xSaherelmWorkspace | <strong>وضعیت:</strong> تغییرات کامیت نشده</div>
<main>
<div class="section"><h2>خلاصه تغییرات</h2>
<p>بازسازی سیستم Logging: انتقال logging از xCommons به xLoggingService، middleware جدید، OpenTelemetry integration، و اعمال در تمام API.</p>
<div class="ok"><strong>هدف:</strong> متحد‌کردن logging و افزایش قابلیت رصد سیستم.</div>
</div>
<div class="section"><h2>1️⃣ Modules/xCommons</h2>
<ul><li><span class="badge rm">حذف</span> <code>Middlewares/XRequestLogger.cs</code></li>
<li><span class="badge mod">تغییر</span> <code>XMiddlewareExtensions.cs</code></li>
<li><span class="badge mod">تغییر</span> <code>XLoggerModel.cs</code> - اضافه Exception property</li></ul>
</div>
<div class="section"><h2>2️⃣ Modules/xLoggingService</h2>
<ul><li><span class="badge added">جدید</span> <code>MIddlewares/XRequestLoggingMiddleware.cs</code></li>
<li><span class="badge mod">تغییر</span> DI - اضافه OpenTelemetry methods</li>
<li><span class="badge mod">تغییر</span> xLoggingService.csproj - به‌روزرسانی packages</li></ul>
<div class="warn">⚠️ توجه: پوشه "MIddlewares" typo است</div>
</div>
<div class="section"><h2>3️⃣ xAiApi</h2>
<ul><li><span class="badge mod">تغییر</span> .gitignore، Program.cs، Startup.cs، xAiApi.csproj</li>
<li>اضافه xLoggingService، OpenTelemetry logging</li></ul>
</div>
<div class="section"><h2>4️⃣ xAiMcpServer</h2>
<ul><li><span class="badge mod">تغییر</span> .gitignore، Program.cs، Startup.cs</li>
<li>یکسان با xAiApi</li></ul>
</div>
<div class="section"><h2>5️⃣ xApi</h2>
<div class="note">بدون تغییر - بررسی کنید</div>
</div>
<div class="section"><h2>6️⃣ xIds</h2>
<ul><li><span class="badge mod">تغییر</span> Program.cs، Startup.cs، xIds.csproj</li>
<li>اضافه xLoggingService و OpenTelemetry</li></ul>
</div>
<div class="section"><h2>📊 آمار</h2>
<table><tr><th>ماژول</th><th>فایل‌ها</th><th>افزوده</th><th>حذف</th></tr>
<tr><td>xCommons</td><td>3</td><td>5</td><td>159</td></tr>
<tr><td>xLoggingService</td><td>2</td><td>90</td><td>9</td></tr>
<tr><td>xAiApi</td><td>4</td><td>27</td><td>5</td></tr>
<tr><td>xAiMcpServer</td><td>3</td><td>13</td><td>1</td></tr>
<tr><td>xIds</td><td>4</td><td>39</td><td>16</td></tr></table>
</div>
<div class="section"><h2>🎯 خطوات بعدی</h2>
<ul><li>v02: تصحیح typo MIddlewares</li>
<li>v02: هم‌ترازی xApi</li>
<li>v02: آزمایش Logging</li></ul>
</div>
</main>
<footer><p>گزارش تغییرات | ۱۴۰۵/۰۸/۱۷ | 2026-11-09 | v01</p></footer>
</div>
</body>
</html>
@@ -0,0 +1,136 @@
================================================================================
Commit Message - xSaherelmWorkspace
تاریخ: ۱۴۰۵/۰۸/۱۷ (2026-11-09)
نسخه مستند: v01
گزارش کامل: Documents/Docs/ChangeLogs/1405-08-17-v01.html
================================================================================
هدف: بازسازی سیستم Logging، اضافه OpenTelemetry، انتقال middleware logging
از xCommons به xLoggingService، یکپارچگی در تمام API و خدمات.
وضعیت: تغییرات کامیت نشده
================================================================================
[1] MODULES / xCommons - حذف Logging Responsibilities
================================================================================
1.1) حذف XRequestLogger Middleware
- حذف: Modules/xCommons/Middlewares/XRequestLogger.cs (144 خط)
- دلیل: منتقل شده به xLoggingService با بهبوری
1.2) تغییر Extensions
- فایل: XMiddlewareExtensions.cs
- تغییر: حذف متد UseXRequestLogger()
- نتیجه: کلاس اکنون خالی است
1.3) بهبود XLoggerModel
- اضافه: Exception property = null
- تنظیم: ترتیب Properties
================================================================================
[2] MODULES / xLoggingService - Enhancement
================================================================================
2.1) Middleware جدید
- فایل: MIddlewares/XRequestLoggingMiddleware.cs (NEW)
- ویژگی: Simple/Full logging modes
- قابلیت: HTTP request/response logging، exception handling
⚠️ توجه: نام پوشه "MIddlewares" typo است - باید تصحیح شود
2.2) توسعه DI
- متد: AddXTelemetryLogger() - logging configuration
- متد: AddXTelemetry() - host builder extension
- متد: UseXRequestLogger() - middleware registration
2.3) به‌روزرسانی Dependencies
- OpenTelemetry.Extensions.Hosting v1.6.0
- OpenTelemetry.Instrumentation.Http v1.6.0
- OpenTelemetry.Instrumentation.AspNetCore v1.6.0
- OpenTelemetry.Exporter.OpenTelemetryProtocol v1.6.0
- Microsoft.Extensions.Logging.Console v5.0.0
================================================================================
[3] xAiApi - Logging Integration
================================================================================
فایل‌های تغییر:
- .gitignore: +Logs
- Program.cs: +xLoggingService، +AddXTelemetryLogger، +AddXTelemetry
- Startup.cs: +UseXRequestLogger (non-development)
- xAiApi.csproj: +xLoggingService reference
================================================================================
[4] xAiMcpServer - Logging Integration
================================================================================
یکسان با xAiApi:
- .gitignore: +Logs
- Program.cs: Telemetry configuration
- Startup.cs: Request logging middleware
================================================================================
[5] xApi - No Changes
================================================================================
وضعیت: بدون تغییر - بررسی کنید
================================================================================
[6] xIds - Logging Integration & Refactoring
================================================================================
تغییرات:
- Program.cs: Arrow → معمولی، +Telemetry
- Startup.cs: isDevelopmentEnvironment var، +logging middleware
- xIds.csproj: +xLoggingService reference
================================================================================
VALIDATION
================================================================================
✓ git diff تمام modules بررسی شد
✓ فایل‌های جدید و حذف شده شناسایی شدند
⚠️ باید انجام شود:
- build تمام projects
- unit/integration tests
- manual logging testing
- OpenTelemetry configuration
================================================================================
COMMIT TITLE (Conventional Commits)
================================================================================
feat: refactor logging with OpenTelemetry integration
refactor: migrate XRequestLogger to xLoggingService
- Move Logging from xCommons to xLoggingService
- Add new XRequestLoggingMiddleware
- Integrate OpenTelemetry (v1.6.0)
- Apply logging across xAiApi, xAiMcpServer, xIds
- Update .gitignore for Logs folders
Breaking Changes:
- UseXRequestLogger now in xLoggingService.DI
- OpenTelemetry packages updated
================================================================================
NEXT VERSIONS (v02, v03)
================================================================================
v02:
- تصحیح typo: MIddlewares → Middlewares
- هم‌ترازی xApi
- آزمایش جامع
v03:
- Structured Logging (JSON)
- OpenTelemetry Exporters
================================================================================
برای نسخه بعدی:
1405-08-17-v02.html
CommitMessage-1405-08-17-v02.txt
===============================================================================
+1 -1
Submodule xAiApi updated: c24c14eb74...5656ec07d5
+1 -1
Submodule xApi updated: 18eb5d92e1...374c3258ef
+1 -1
Submodule xIds updated: b311b1e391...8d392b3d84