Troubleshooting
Common issues and solutions for Sherlock AI.
Installation Issues
Import Error
Problem: ModuleNotFoundError: No module named 'sherlock_ai'
Solution:
Dependencies Missing
Problem: Missing dependencies for optional features
Solution:
# For MongoDB support
pip install pymongo
# For code analysis
pip install astor groq
# For API client
pip install requests
Configuration Issues
Logs Not Created
Problem: Log files not appearing in logs directory
Solution: 1. Check directory permissions 2. Verify configuration:
Duplicate Logs
Problem: Seeing duplicate log entries
Solution:
- Don't call sherlock_ai() multiple times
- In FastAPI with reload, initialize only once
Auto-Instrumentation Not Working
Problem: FastAPI routes not being monitored
Solution:
# Initialize BEFORE creating app
logging_manager = SherlockAI(config=config)
logging_manager.setup()
# THEN create app
app = FastAPI()
Monitoring Issues
Performance Logs Missing
Problem: No performance logs appearing
Solution:
- Ensure @log_performance decorator is applied
- Check that performance log file is enabled:
Memory Monitoring Not Detailed
Problem: Memory logs don't show traced memory
Solution:
Storage Issues
MongoDB Connection Failed
Problem: Error insights not being stored
Solution:
import os
from sherlock_ai.storage import MongoManager
os.environ["MONGO_URI"] = "mongodb://localhost:27017"
# Verify connection
mongo = MongoManager()
print(f"MongoDB enabled: {mongo.enabled}")
API Client Authentication Failed
Problem: HTTP 401 when sending insights
Solution:
import os
# Set API key
os.environ["SHERLOCK_AI_API_KEY"] = "your-valid-api-key"
# Verify
print(os.getenv("SHERLOCK_AI_API_KEY"))
Performance Issues
High Memory Usage
Problem: tracemalloc causing high memory usage
Solution:
Slow Performance
Problem: Monitoring adds too much overhead
Solution:
1. Use min_duration to reduce logging:
- Disable unused monitoring:
File System Issues
Disk Space Full
Problem: Running out of disk space
Solution: 1. Reduce log file sizes:
- Clean up old logs:
Permission Denied
Problem: Cannot write to logs directory
Solution:
# Fix permissions
sudo chown -R your_user:your_group /var/log/myapp
sudo chmod -R 755 /var/log/myapp
Getting Help
If you encounter issues not covered here:
- Check the GitHub Issues
- Enable debug logging:
- Check logging statistics: