get_logs
Retrieve and filter application logs by lines, level, time, and source to monitor and troubleshoot Gradle-based Tomcat applications efficiently.
Instructions
Retrieve log entries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| level | No | Minimum log level (DEBUG, INFO, WARN, ERROR) | |
| lines | No | Number of recent log lines to retrieve (default: 100) | |
| since | No | ISO 8601 timestamp to filter logs from | |
| source | No | Filter by log source (stdout, stderr) |
Implementation Reference
- src/log-manager.js:70-102 (handler)The main implementation of the get_logs tool. Filters the in-memory log buffer by level (minimum priority), since timestamp, source, and returns the most recent 'lines' number of matching log entries.getLogs(options = {}) { const { lines = 100, level = null, since = null, source = null } = options; let filteredLogs = [...this.logBuffer]; if (level) { const levelPriority = { 'DEBUG': 0, 'INFO': 1, 'WARN': 2, 'ERROR': 3 }; const minPriority = levelPriority[level.toUpperCase()] || 0; filteredLogs = filteredLogs.filter(log => (levelPriority[log.level] || 0) >= minPriority ); } if (since) { const sinceDate = new Date(since); filteredLogs = filteredLogs.filter(log => new Date(log.timestamp) >= sinceDate ); } if (source) { filteredLogs = filteredLogs.filter(log => log.source === source ); } return filteredLogs.slice(-lines); }
- src/tools/index.js:63-86 (schema)Input schema for the get_logs tool, defining parameters: lines (number, default 100), level (enum), since (ISO string), source (enum).inputSchema: { type: "object", properties: { lines: { type: "number", description: "Number of recent log lines to retrieve (default: 100)", default: 100 }, level: { type: "string", description: "Minimum log level (DEBUG, INFO, WARN, ERROR)", enum: ["DEBUG", "INFO", "WARN", "ERROR"] }, since: { type: "string", description: "ISO 8601 timestamp to filter logs from" }, source: { type: "string", description: "Filter by log source (stdout, stderr)", enum: ["stdout", "stderr"] } } }
- src/tools/index.js:60-87 (registration)Registration of the get_logs tool in the TOOLS export array, including name, description, and input schema.{ name: "get_logs", description: "Retrieve log entries", inputSchema: { type: "object", properties: { lines: { type: "number", description: "Number of recent log lines to retrieve (default: 100)", default: 100 }, level: { type: "string", description: "Minimum log level (DEBUG, INFO, WARN, ERROR)", enum: ["DEBUG", "INFO", "WARN", "ERROR"] }, since: { type: "string", description: "ISO 8601 timestamp to filter logs from" }, source: { type: "string", description: "Filter by log source (stdout, stderr)", enum: ["stdout", "stderr"] } } } },
- src/tools/index.js:126-132 (handler)Dispatch handler in handleToolCall function that maps tool arguments to logManager.getLogs call.case "get_logs": return logManager.getLogs({ lines: args.lines, level: args.level, since: args.since, source: args.source });