Create a file logging behaviour.
If the agent-manager is set up as systemd service for example, allow a configuration where the agent-manager outputs will logged into file. /var/log/agent-manager.log
This must be enabled by default when running as systemd service.
The logfile must be rotated.
Create a file logging behaviour.
If the agent-manager is set up as systemd service for example, allow a configuration where the agent-manager outputs will logged into file. /var/log/agent-manager.log
This must be enabled by default when running as systemd service.
The logfile must be rotated.
I'll implement file logging with the following approach:
Enhance the logger module to support both console and file output
Add configuration options for file logging (path, enable/disable, rotation settings)
Implement log file rotation to prevent unlimited growth
Make it enabled by default when running as a systemd service
Update the systemd service file to handle log file permissions and rotation
Let me start working on this implementation.
@fszontagh I'm starting work on this issue now!
I'll implement file logging with the following approach:
1. Enhance the logger module to support both console and file output
2. Add configuration options for file logging (path, enable/disable, rotation settings)
3. Implement log file rotation to prevent unlimited growth
4. Make it enabled by default when running as a systemd service
5. Update the systemd service file to handle log file permissions and rotation
Let me start working on this implementation.
Added write permission for /var/log directory via ReadWritePaths
4. Auto-Detection
The logger automatically detects when running under systemd (checks for JOURNAL_STREAM or INVOCATION_ID environment variables) and enables file logging by default.
How It Works
Initialization: On startup, the logger creates the log directory if it doesn't exist
Writing: All log messages (INFO, WARN, ERROR, DEBUG, job lifecycle events, webhook events) are written to both console and file
Rotation: When the log file reaches MAX_LOG_SIZE, it's automatically rotated:
Current log renamed to .1
Previous .1 renamed to .2, etc.
Oldest log (beyond MAX_LOG_FILES) is deleted
Recovery: If file writing fails, logging continues to console without crashing
Testing
I tested the implementation by:
Starting the server with file logging enabled
Verifying log file creation at /tmp/test-agent-manager.log
Confirming all log types are written correctly
Validating ANSI color codes are stripped from file output
Checking timestamp inclusion in file logs
Next Steps
To use this feature:
For systemd: Simply restart the service - file logging is enabled by default
For manual runs: Set FILE_LOGGING_ENABLED=true in your .env file
Logs will be written to /var/log/agent-manager.log (or your configured path)
The implementation is complete and has been committed and pushed to the repository!
@fszontagh I've successfully implemented the file logging feature! Here's what was added:
## Implementation Summary
### 1. **Enhanced Logger Module** (`src/logger.js`)
- Added file logging support with automatic rotation
- Logs are rotated when they reach `MAX_LOG_SIZE` (default: 10MB)
- Keeps up to `MAX_LOG_FILES` rotated files (default: 5)
- File naming: `agent-manager.log`, `agent-manager.log.1`, `agent-manager.log.2`, etc.
- ANSI color codes are stripped from file output for better readability
- Timestamps are always included in file logs (even if disabled for console)
### 2. **Configuration Options** (`.env.example`)
Added new environment variables:
- `FILE_LOGGING_ENABLED` - Enable/disable file logging (default: false, auto-enabled for systemd)
- `LOG_FILE_PATH` - Path to log file (default: `/var/log/agent-manager.log`)
- `MAX_LOG_SIZE` - Max size in bytes before rotation (default: 10485760 = 10MB)
- `MAX_LOG_FILES` - Number of rotated files to keep (default: 5)
### 3. **Systemd Service** (`agent-manager.service`)
- File logging is **enabled by default** when running as systemd service
- Environment variables set: `FILE_LOGGING_ENABLED=true`, `LOG_FILE_PATH=/var/log/agent-manager.log`
- Added write permission for `/var/log` directory via `ReadWritePaths`
### 4. **Auto-Detection**
The logger automatically detects when running under systemd (checks for `JOURNAL_STREAM` or `INVOCATION_ID` environment variables) and enables file logging by default.
## How It Works
1. **Initialization**: On startup, the logger creates the log directory if it doesn't exist
2. **Writing**: All log messages (INFO, WARN, ERROR, DEBUG, job lifecycle events, webhook events) are written to both console and file
3. **Rotation**: When the log file reaches `MAX_LOG_SIZE`, it's automatically rotated:
- Current log renamed to `.1`
- Previous `.1` renamed to `.2`, etc.
- Oldest log (beyond `MAX_LOG_FILES`) is deleted
4. **Recovery**: If file writing fails, logging continues to console without crashing
## Testing
I tested the implementation by:
- Starting the server with file logging enabled
- Verifying log file creation at `/tmp/test-agent-manager.log`
- Confirming all log types are written correctly
- Validating ANSI color codes are stripped from file output
- Checking timestamp inclusion in file logs
## Next Steps
To use this feature:
1. For systemd: Simply restart the service - file logging is enabled by default
2. For manual runs: Set `FILE_LOGGING_ENABLED=true` in your `.env` file
3. Logs will be written to `/var/log/agent-manager.log` (or your configured path)
The implementation is complete and has been committed and pushed to the repository!
**Commit**: b2155b3
@fszontagh I'm on it! I'll update the CLAUDE.md file to document the new file logging feature and mention the log file location for debugging purposes. Once that's done, I'll close this issue.
@fszontagh I'm on it! I'll update the CLAUDE.md file to document the new file logging feature and mention the log file location for debugging purposes. Once that's done, I'll close this issue.
Closing this issue as requested. The file logging feature is complete and fully documented!
@fszontagh ✅ Documentation updated! I've updated CLAUDE.md with comprehensive information about the file logging feature:
## Changes Made
### 1. **Logger Component Section** (Lines 69-79)
Enhanced the Logger description with:
- File logging support details
- Automatic rotation configuration
- Default log file location and settings
- ANSI color stripping for file output
### 2. **Environment Configuration Section** (Lines 180-188)
Added new "File Logging Configuration" subsection with:
- All configuration options (`FILE_LOGGING_ENABLED`, `LOG_FILE_PATH`, `MAX_LOG_SIZE`, `MAX_LOG_FILES`)
- Default values and behavior
- Note about automatic systemd detection
### 3. **System Management Section** (Lines 144-149)
Added debugging information:
- Command to view the log file (`tail -f /var/log/agent-manager.log`)
- Explanation of what gets logged
- Rotation behavior details
- Clear guidance for troubleshooting
### 4. **Important Patterns Section** (Line 266)
Added file logging to the list of important patterns
## For Debugging
Claude (and any developer) can now easily find and use the log file at `/var/log/agent-manager.log` for debugging. The documentation clearly states:
- When file logging is enabled (systemd auto-detection)
- Where the log file is located
- How to view it
- What information it contains
**Commit**: 7eb85de
Closing this issue as requested. The file logging feature is complete and fully documented!
Create a file logging behaviour. If the agent-manager is set up as systemd service for example, allow a configuration where the agent-manager outputs will logged into file. /var/log/agent-manager.log
This must be enabled by default when running as systemd service. The logfile must be rotated.
@fszontagh I'm starting work on this issue now!
I'll implement file logging with the following approach:
Let me start working on this implementation.
@fszontagh I've successfully implemented the file logging feature! Here's what was added:
Implementation Summary
1. Enhanced Logger Module (
src/logger.js)MAX_LOG_SIZE(default: 10MB)MAX_LOG_FILESrotated files (default: 5)agent-manager.log,agent-manager.log.1,agent-manager.log.2, etc.2. Configuration Options (
.env.example)Added new environment variables:
FILE_LOGGING_ENABLED- Enable/disable file logging (default: false, auto-enabled for systemd)LOG_FILE_PATH- Path to log file (default:/var/log/agent-manager.log)MAX_LOG_SIZE- Max size in bytes before rotation (default: 10485760 = 10MB)MAX_LOG_FILES- Number of rotated files to keep (default: 5)3. Systemd Service (
agent-manager.service)FILE_LOGGING_ENABLED=true,LOG_FILE_PATH=/var/log/agent-manager.log/var/logdirectory viaReadWritePaths4. Auto-Detection
The logger automatically detects when running under systemd (checks for
JOURNAL_STREAMorINVOCATION_IDenvironment variables) and enables file logging by default.How It Works
MAX_LOG_SIZE, it's automatically rotated:.1.1renamed to.2, etc.MAX_LOG_FILES) is deletedTesting
I tested the implementation by:
/tmp/test-agent-manager.logNext Steps
To use this feature:
FILE_LOGGING_ENABLED=truein your.envfile/var/log/agent-manager.log(or your configured path)The implementation is complete and has been committed and pushed to the repository!
Commit:
b2155b3update claude.md based on this new feature. For debbugging, claude can use the /var/log/agent-manager.log file
IF you ready, you can close this issue
@fszontagh I'm on it! I'll update the CLAUDE.md file to document the new file logging feature and mention the log file location for debugging purposes. Once that's done, I'll close this issue.
@fszontagh ✅ Documentation updated! I've updated CLAUDE.md with comprehensive information about the file logging feature:
Changes Made
1. Logger Component Section (Lines 69-79)
Enhanced the Logger description with:
2. Environment Configuration Section (Lines 180-188)
Added new "File Logging Configuration" subsection with:
FILE_LOGGING_ENABLED,LOG_FILE_PATH,MAX_LOG_SIZE,MAX_LOG_FILES)3. System Management Section (Lines 144-149)
Added debugging information:
tail -f /var/log/agent-manager.log)4. Important Patterns Section (Line 266)
Added file logging to the list of important patterns
For Debugging
Claude (and any developer) can now easily find and use the log file at
/var/log/agent-manager.logfor debugging. The documentation clearly states:Commit:
7eb85deClosing this issue as requested. The file logging feature is complete and fully documented!