get_logs
Retrieve recent log entries from Gradle Tomcat applications to monitor application behavior, filter by log level, source, or time period for debugging and troubleshooting.
Instructions
Retrieve log entries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lines | No | Number of recent log lines to retrieve (default: 100) | |
| level | No | Minimum log level (DEBUG, INFO, WARN, ERROR) | |
| 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)Executes the get_logs tool logic: filters the in-memory log buffer by lines, level, since timestamp, and source, returning the most recent matching 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)Defines the input schema for the get_logs tool, specifying parameters for log retrieval.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 (registration)Registers the get_logs tool handler by mapping the tool name to logManager.getLogs call in the tool dispatcher.case "get_logs": return logManager.getLogs({ lines: args.lines, level: args.level, since: args.since, source: args.source });
- src/tools/index.js:60-87 (registration)Tool registration in the TOOLS array export, including name, description, and input schema for MCP protocol.{ 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"] } } } },