@@ -160,6 +160,115 @@ du -sh logs/*
160
160
161
161
---
162
162
163
+ ## 🖥️ Admin UI Log Viewer
164
+
165
+ MCP Gateway includes a built-in log viewer in the Admin UI that provides real-time monitoring, filtering, and export capabilities without requiring direct file access.
166
+
167
+ ### Enabling the Log Viewer
168
+
169
+ The log viewer is automatically available when the Admin UI is enabled:
170
+
171
+ ``` bash
172
+ # Enable Admin UI (includes log viewer)
173
+ MCPGATEWAY_UI_ENABLED=true
174
+
175
+ # Configure in-memory log buffer size (default: 1MB)
176
+ LOG_BUFFER_SIZE_MB=2 # Increase for more log history
177
+ ```
178
+
179
+ ### Features
180
+
181
+ #### Real-Time Monitoring
182
+ - ** Live streaming** via Server-Sent Events (SSE)
183
+ - ** Automatic updates** as new logs are generated
184
+ - ** Visual indicators** with pulse animation for new entries
185
+ - ** Color-coded severity levels** :
186
+ - Debug: Gray
187
+ - Info: Blue
188
+ - Warning: Yellow
189
+ - Error: Red
190
+ - Critical: Purple
191
+
192
+ #### Filtering & Search
193
+ - ** Filter by log level** : Debug, Info, Warning, Error, Critical
194
+ - ** Filter by entity type** : Tool, Resource, Server, Gateway
195
+ - ** Full-text search** : Search within log messages
196
+ - ** Time range filtering** : Filter by date/time range
197
+ - ** Request ID tracing** : Track logs for specific requests
198
+
199
+ #### Export Capabilities
200
+ - ** Export to JSON** : Download filtered logs as JSON file
201
+ - ** Export to CSV** : Download filtered logs as CSV file
202
+ - ** Download log files** : Direct access to rotated log files (if file logging enabled)
203
+
204
+ ### Accessing the Log Viewer
205
+
206
+ 1 . Navigate to the Admin UI: ` http://localhost:4444/admin `
207
+ 2 . Click the ** "Logs"** tab in the navigation
208
+ 3 . Use the filter controls to refine your view:
209
+ - Select entity type from dropdown
210
+ - Choose minimum log level
211
+ - Enter search terms
212
+ - Set pagination options
213
+
214
+ ### API Endpoints
215
+
216
+ The log viewer also exposes REST API endpoints for programmatic access:
217
+
218
+ ``` bash
219
+ # Get filtered logs
220
+ curl -H " Authorization: Bearer $TOKEN " \
221
+ " http://localhost:4444/admin/logs?level=error&limit=50"
222
+
223
+ # Stream logs in real-time (SSE)
224
+ curl -H " Authorization: Bearer $TOKEN " \
225
+ " http://localhost:4444/admin/logs/stream"
226
+
227
+ # Export logs as JSON
228
+ curl -H " Authorization: Bearer $TOKEN " \
229
+ " http://localhost:4444/admin/logs/export?format=json" \
230
+ -o logs.json
231
+
232
+ # List available log files
233
+ curl -H " Authorization: Bearer $TOKEN " \
234
+ " http://localhost:4444/admin/logs/file"
235
+ ```
236
+
237
+ ### Buffer Management
238
+
239
+ The log viewer uses an in-memory circular buffer with configurable size:
240
+
241
+ - ** Default size** : 1MB (approximately 2000-5000 log entries)
242
+ - ** Size-based eviction** : Oldest logs automatically removed when buffer is full
243
+ - ** No persistence** : Buffer is cleared on server restart
244
+ - ** Performance** : Minimal memory overhead with O(1) operations
245
+
246
+ ### Configuration Options
247
+
248
+ | Variable | Description | Default | Example |
249
+ | -------------------- | ------------------------------------ | ------- | ------- |
250
+ | ` LOG_BUFFER_SIZE_MB ` | In-memory buffer size for UI viewer | ` 1 ` | ` 2 ` , ` 5 ` , ` 10 ` |
251
+
252
+ ### Best Practices
253
+
254
+ 1 . ** Adjust buffer size** based on your monitoring needs:
255
+ - Development: 1-2MB is usually sufficient
256
+ - Production: Consider 5-10MB for longer history
257
+
258
+ 2 . ** Use filters** to focus on relevant logs:
259
+ - Filter by error level during troubleshooting
260
+ - Filter by entity when debugging specific components
261
+
262
+ 3 . ** Export regularly** if you need to preserve logs:
263
+ - The buffer is in-memory only and clears on restart
264
+ - Export important logs to JSON/CSV for archival
265
+
266
+ 4 . ** Combine with file logging** for persistence:
267
+ - UI viewer for real-time monitoring
268
+ - File logs for long-term storage and analysis
269
+
270
+ ---
271
+
163
272
## 📡 Streaming Logs (Containers)
164
273
165
274
``` bash
0 commit comments