Skip to content

Trader: Diagnostics logging - Implement file-based error logging - #296

Open
konard wants to merge 3 commits into
mainfrom
issue-114-8bf2b12b
Open

Trader: Diagnostics logging - Implement file-based error logging#296
konard wants to merge 3 commits into
mainfrom
issue-114-8bf2b12b

Conversation

@konard

@konard konard commented Sep 13, 2025

Copy link
Copy Markdown
Member

📋 Issue Reference

Fixes #114

🔧 Implementation Summary

This PR implements comprehensive file-based error logging for the TraderBot application that works across all operating systems (Windows, Linux, macOS).

Changes Made

1. Added NLog Package

  • Added NLog.Extensions.Logging v5.3.8 for cross-platform file logging capabilities

2. NLog Configuration (NLog.config)

  • Error Logs: logs/errors-{date}.log - Captures errors and above
  • All Logs: logs/all-{date}.log - Captures all log levels (Info and above)
  • Console Logs: For development and debugging
  • Log Rotation: 10MB max file size with automatic archiving
  • Archive Retention: 7 error log archives, 3 all log archives
  • Cross-platform paths: Uses ${basedir} for OS-agnostic relative paths
  • Concurrency safe: Configured with concurrentWrites="true"

3. Application Updates

  • Updated Program.cs to configure NLog as the logging provider
  • Modified TraderBot.csproj to copy NLog.config to output directory
  • Updated .gitignore to exclude logs directory from version control

🌍 Cross-Platform Compatibility

The solution works on all operating systems because:

  • NLog is fully cross-platform (Windows, Linux, macOS)
  • Uses OS-agnostic path patterns (${basedir})
  • Automatic directory creation by NLog
  • Platform-normalized path separators

📁 Log Structure

TraderBot/
├── logs/
│   ├── errors-2025-09-13.log     # Error and critical logs
│   ├── all-2025-09-13.log        # All application logs
│   └── archived/                 # Rotated log archives
│       ├── errors-1.log
│       └── all-1.log

🧪 Testing

  • ✅ Project builds successfully
  • ✅ NLog configuration validated
  • ✅ Dependencies restored correctly
  • ✅ Cross-platform file paths configured

The implementation ensures all errors are now automatically logged to files while maintaining console output for development purposes.

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #114
@konard konard self-assigned this Sep 13, 2025
- Add NLog.Extensions.Logging package for cross-platform file logging
- Configure NLog with separate error and all logs files
- Add log rotation and archiving (10MB files, 7 error archives, 3 all archives)
- Update Program.cs to use NLog provider
- Add logs/ directory to .gitignore
- Ensure NLog.config is copied to output directory

Fixes #114

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Trader: Diagnostics logging Trader: Diagnostics logging - Implement file-based error logging Sep 13, 2025
@konard
konard marked this pull request as ready for review September 13, 2025 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trader: Diagnostics logging

1 participant