From bb9e5021ea4aba27165bc8dfca40de2108cdd725 Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 04:33:33 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #114 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Bot/issues/114 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..f06c9248 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Bot/issues/114 +Your prepared branch: issue-114-8bf2b12b +Your prepared working directory: /tmp/gh-issue-solver-1757727208363 + +Proceed. \ No newline at end of file From 4bddd7b68c8ac9bce727556db6e22152848f0145 Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 04:41:36 +0300 Subject: [PATCH 2/3] Implement file-based error logging for all OSes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- csharp/TraderBot/.gitignore | 3 +- csharp/TraderBot/NLog.config | 46 +++++++++++++++++++++++++++++++ csharp/TraderBot/Program.cs | 7 +++++ csharp/TraderBot/TraderBot.csproj | 7 +++++ examples/test_logging.cs | 30 ++++++++++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 csharp/TraderBot/NLog.config create mode 100644 examples/test_logging.cs diff --git a/csharp/TraderBot/.gitignore b/csharp/TraderBot/.gitignore index 361e824f..4f4a3286 100644 --- a/csharp/TraderBot/.gitignore +++ b/csharp/TraderBot/.gitignore @@ -1,3 +1,4 @@ appsettings.json log.txt -log.*.txt \ No newline at end of file +log.*.txt +logs/ \ No newline at end of file diff --git a/csharp/TraderBot/NLog.config b/csharp/TraderBot/NLog.config new file mode 100644 index 00000000..bc44ea8a --- /dev/null +++ b/csharp/TraderBot/NLog.config @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/csharp/TraderBot/Program.cs b/csharp/TraderBot/Program.cs index e5ac64bb..e9f59dc1 100644 --- a/csharp/TraderBot/Program.cs +++ b/csharp/TraderBot/Program.cs @@ -2,11 +2,18 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.UserSecrets; +using Microsoft.Extensions.Logging; using Tinkoff.InvestApi; using TraderBot; +using NLog.Extensions.Logging; var builder = Host.CreateDefaultBuilder(args); var host = builder + .ConfigureLogging(logging => + { + logging.ClearProviders(); + logging.AddNLog(); + }) .ConfigureServices((context, services) => { services.AddSingleton(_ => diff --git a/csharp/TraderBot/TraderBot.csproj b/csharp/TraderBot/TraderBot.csproj index 12374722..4bcd23e8 100644 --- a/csharp/TraderBot/TraderBot.csproj +++ b/csharp/TraderBot/TraderBot.csproj @@ -13,8 +13,15 @@ + + + + PreserveNewest + + + diff --git a/examples/test_logging.cs b/examples/test_logging.cs new file mode 100644 index 00000000..0fcc0c8f --- /dev/null +++ b/examples/test_logging.cs @@ -0,0 +1,30 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + +// Create minimal host to test logging +var services = new ServiceCollection(); +services.AddLogging(builder => +{ + builder.ClearProviders(); + builder.AddNLog(); +}); + +var serviceProvider = services.BuildServiceProvider(); +var logger = serviceProvider.GetRequiredService>(); + +// Test different log levels +logger.LogInformation("This is an information message"); +logger.LogWarning("This is a warning message"); +logger.LogError("This is an error message that should be logged to file"); + +try +{ + throw new Exception("Test exception for logging"); +} +catch (Exception ex) +{ + logger.LogError(ex, "Test exception caught and logged"); +} + +Console.WriteLine("Logging test completed. Check the logs directory for files."); \ No newline at end of file From 2d3261b4e97aa018beddada3614f3a3375df9c0f Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 04:42:26 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index f06c9248..00000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Bot/issues/114 -Your prepared branch: issue-114-8bf2b12b -Your prepared working directory: /tmp/gh-issue-solver-1757727208363 - -Proceed. \ No newline at end of file