diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Migration.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Migration.cs index 23012706..4bb989bf 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Migration.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Migration.cs @@ -53,7 +53,7 @@ public partial class ConversationService #if DEBUG Console.WriteLine($"\r\n{error}\r\n"); #else - _logger.LogError($"{error}"); + _logger.LogError(ex, $"{error}"); #endif } } diff --git a/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Pdf.cs b/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Pdf.cs index a1589de9..2336363a 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Pdf.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Pdf.cs @@ -66,7 +66,7 @@ public partial class FileInstructService } catch (Exception ex) { - _logger.LogError($"Error when analyzing pdf in file service: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when analyzing pdf in file service."); return content; } finally @@ -113,7 +113,7 @@ public partial class FileInstructService } catch (Exception ex) { - _logger.LogWarning($"Error when saving pdf file: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving pdf file."); continue; } } @@ -141,7 +141,7 @@ public partial class FileInstructService } catch (Exception ex) { - _logger.LogWarning($"Error when converting pdf file to images ({file}): {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when converting pdf file to images ({file})."); continue; } } diff --git a/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.SelectFile.cs b/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.SelectFile.cs index c789e069..13525fb1 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.SelectFile.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.SelectFile.cs @@ -108,7 +108,7 @@ public partial class FileInstructService } catch (Exception ex) { - _logger.LogWarning($"Error when selecting files. {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when selecting files."); return new List(); } } diff --git a/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Audio.cs b/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Audio.cs index 1db0d036..45841749 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Audio.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Audio.cs @@ -24,7 +24,7 @@ public partial class LocalFileStorageService } catch (Exception ex) { - _logger.LogWarning($"Error when saving speech file. {fileName} ({conversationId})\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving speech file. {fileName} (conv id: {conversationId})"); return false; } } diff --git a/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Conversation.cs b/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Conversation.cs index d296e0b3..c1accd30 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Conversation.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Conversation.cs @@ -153,7 +153,7 @@ public partial class LocalFileStorageService } catch (Exception ex) { - _logger.LogWarning($"Error when saving message file {file.FileName}: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving message file {file.FileName} (conv id: {conversationId})."); continue; } } @@ -333,7 +333,7 @@ public partial class LocalFileStorageService } catch (Exception ex) { - _logger.LogWarning($"Error when getting message file screenshots {file} (messageId: {messageId}), Error: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting message file screenshots {file} (messageId: {messageId})"); return files; } } diff --git a/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.KnowledgeBase.cs b/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.KnowledgeBase.cs index 594b7608..8fc6bb0a 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.KnowledgeBase.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.KnowledgeBase.cs @@ -31,9 +31,8 @@ public partial class LocalFileStorageService } catch (Exception ex) { - _logger.LogWarning($"Error when saving knowledge file " + - $"(Vector store provider: {vectorStoreProvider}, Collection: {collectionName}, File name: {fileName})." + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving knowledge file " + + $"(Vector store provider: {vectorStoreProvider}, Collection: {collectionName}, File name: {fileName})."); return false; } } diff --git a/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.User.cs b/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.User.cs index 97da2d6f..21f522b2 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.User.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.User.cs @@ -40,7 +40,7 @@ public partial class LocalFileStorageService } catch (Exception ex) { - _logger.LogWarning($"Error when saving user avatar: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving user avatar (user id: {_user.Id})"); return false; } } diff --git a/src/Infrastructure/BotSharp.Core/Instructs/Functions/ExecuteTemplateFn.cs b/src/Infrastructure/BotSharp.Core/Instructs/Functions/ExecuteTemplateFn.cs index 8b4763f8..346218dd 100644 --- a/src/Infrastructure/BotSharp.Core/Instructs/Functions/ExecuteTemplateFn.cs +++ b/src/Infrastructure/BotSharp.Core/Instructs/Functions/ExecuteTemplateFn.cs @@ -84,7 +84,7 @@ public class ExecuteTemplateFn : IFunctionCallback catch (Exception ex) { var error = $"Error when getting agent {agent.Name} instruction response."; - _logger.LogWarning($"{error} {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"{error} (template name: {templateName})"); return error; } diff --git a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs index 4b7b5efb..d257b855 100644 --- a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs +++ b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs @@ -45,7 +45,7 @@ public partial class InstructService } catch (Exception ex) { - _logger.LogWarning($"Error when getting ai response, {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting ai response"); } return result; diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Crontab.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Crontab.cs index 5d3eb865..4a99027a 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Crontab.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Crontab.cs @@ -26,7 +26,7 @@ public partial class FileRepository } catch (Exception ex) { - _logger.LogError($"Error when saving crontab item: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when saving crontab item (agent id: {cron.AgentId}, conv id: {cron.ConversationId})."); return false; } } @@ -57,7 +57,7 @@ public partial class FileRepository } catch (Exception ex) { - _logger.LogError($"Error when deleting crontab item (${conversationId}): {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when deleting crontab item (conv id: {conversationId})."); return false; } } diff --git a/src/Infrastructure/BotSharp.Core/Statistics/Services/BotSharpStatsService.cs b/src/Infrastructure/BotSharp.Core/Statistics/Services/BotSharpStatsService.cs index 6f9c037e..4e847a4d 100644 --- a/src/Infrastructure/BotSharp.Core/Statistics/Services/BotSharpStatsService.cs +++ b/src/Infrastructure/BotSharp.Core/Statistics/Services/BotSharpStatsService.cs @@ -89,7 +89,7 @@ public class BotSharpStatsService : IBotSharpStatsService } catch (Exception ex) { - _logger.LogError($"Error when updating global stats {input.Metric}-{input.Dimension}-{input.DimRefVal}. {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when updating global stats {input.Metric}-{input.Dimension}-{input.DimRefVal}."); return false; } } diff --git a/src/Plugins/BotSharp.Plugin.AudioHandler/Provider/NativeWhisperProvider.cs b/src/Plugins/BotSharp.Plugin.AudioHandler/Provider/NativeWhisperProvider.cs index 529e2943..a8aef524 100644 --- a/src/Plugins/BotSharp.Plugin.AudioHandler/Provider/NativeWhisperProvider.cs +++ b/src/Plugins/BotSharp.Plugin.AudioHandler/Provider/NativeWhisperProvider.cs @@ -94,7 +94,7 @@ public class NativeWhisperProvider : IAudioTranscription catch (Exception ex) { var error = "Failed to load whisper model"; - _logger.LogWarning($"${error}: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"{error}"); throw new Exception($"{error}: {ex.Message}"); } } diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs index 7d848eb0..c29f43db 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs +++ b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs @@ -195,8 +195,7 @@ public class ChatHubConversationHook : ConversationHookBase } catch (Exception ex) { - _logger.LogWarning($"Failed to init client conversation in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})" + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to init client conversation in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})"); } } @@ -215,8 +214,7 @@ public class ChatHubConversationHook : ConversationHookBase } catch (Exception ex) { - _logger.LogWarning($"Failed to receive assistant message in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})" + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to receive assistant message in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})"); } } @@ -235,8 +233,7 @@ public class ChatHubConversationHook : ConversationHookBase } catch (Exception ex) { - _logger.LogWarning($"Failed to receive assistant message in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})" + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to receive assistant message in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})"); } } @@ -256,8 +253,7 @@ public class ChatHubConversationHook : ConversationHookBase } catch (Exception ex) { - _logger.LogWarning($"Failed to generate sender action in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})" + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to generate sender action in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})"); } } @@ -276,8 +272,7 @@ public class ChatHubConversationHook : ConversationHookBase } catch (Exception ex) { - _logger.LogWarning($"Failed to delete message in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})" + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to delete message in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})"); } } @@ -296,8 +291,7 @@ public class ChatHubConversationHook : ConversationHookBase } catch (Exception ex) { - _logger.LogWarning($"Failed to generate notification in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})" + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to generate notification in {nameof(ChatHubConversationHook)} (conversation id: {conversationId})"); } } #endregion diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs index c5d6b15c..720f3fd0 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs +++ b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs @@ -484,8 +484,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR } catch (Exception ex) { - _logger.LogWarning($"Failed to send content log in {nameof(StreamingLogHook)} (conversation id: {conversationId})." + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to send content log in {nameof(StreamingLogHook)} (conversation id: {conversationId})."); } } @@ -504,8 +503,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR } catch (Exception ex) { - _logger.LogWarning($"Failed to send state log in {nameof(StreamingLogHook)} (conversation id: {conversationId})." + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to send state log in {nameof(StreamingLogHook)} (conversation id: {conversationId})."); } } @@ -524,8 +522,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR } catch (Exception ex) { - _logger.LogWarning($"Failed to send agent queue log in {nameof(StreamingLogHook)} (conversation id: {conversationId})." + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to send agent queue log in {nameof(StreamingLogHook)} (conversation id: {conversationId})."); } } @@ -544,8 +541,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR } catch (Exception ex) { - _logger.LogWarning($"Failed to send state change in {nameof(StreamingLogHook)} (conversation id: {conversationId})." + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to send state change in {nameof(StreamingLogHook)} (conversation id: {conversationId})."); } } diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/WelcomeHook.cs b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/WelcomeHook.cs index 70545305..d664b99d 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/WelcomeHook.cs +++ b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/WelcomeHook.cs @@ -103,8 +103,7 @@ public class WelcomeHook : ConversationHookBase } catch (Exception ex) { - _logger.LogWarning($"Failed to send event in {nameof(WelcomeHook)} (conversation id: {conversationId})." + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to send event in {nameof(WelcomeHook)} (conversation id: {conversationId})."); } } } diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/SignalRHub.cs b/src/Plugins/BotSharp.Plugin.ChatHub/SignalRHub.cs index 63ded25a..9ef3318e 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/SignalRHub.cs +++ b/src/Plugins/BotSharp.Plugin.ChatHub/SignalRHub.cs @@ -64,8 +64,7 @@ public class SignalRHub : Hub } catch (Exception ex) { - _logger.LogWarning($"Failed to add chat group in {nameof(SignalRHub)} (conversation id: {conversationId})." + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Failed to add chat group in {nameof(SignalRHub)} (conversation id: {conversationId})."); } } } diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs index a6b04e49..df46cdfe 100644 --- a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs +++ b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs @@ -64,7 +64,7 @@ public class HandleEmailSenderFn : IFunctionCallback catch (Exception ex) { var msg = $"Failed to send the email. {ex.Message}"; - _logger.LogError($"{msg}\n(Error: {ex.Message}\r\n{ex.InnerException})"); + _logger.LogError(ex, $"{msg}"); message.Content = msg; return false; } diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs index 87d8268b..2895f152 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs +++ b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs @@ -90,7 +90,7 @@ public class EditImageFn : IFunctionCallback catch (Exception ex) { var error = $"Error when getting image edit response. {ex.Message}"; - _logger.LogWarning($"{error}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"{error}"); return error; } } diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/GenerateImageFn.cs b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/GenerateImageFn.cs index a511ebae..151cf4f8 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/GenerateImageFn.cs +++ b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/GenerateImageFn.cs @@ -68,7 +68,7 @@ public class GenerateImageFn : IFunctionCallback catch (Exception ex) { var error = $"Error when generating image."; - _logger.LogWarning($"{error} {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"{error}"); return error; } } diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs index ff19fbf1..6e42af30 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs +++ b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs @@ -108,7 +108,7 @@ public class ReadImageFn : IFunctionCallback catch (Exception ex) { var error = $"Error when analyzing images."; - _logger.LogWarning($"{error} {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"{error}"); return error; } } diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs index 5a2d2d9b..42cc04f2 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs +++ b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs @@ -86,7 +86,7 @@ public class ReadPdfFn : IFunctionCallback catch (Exception ex) { var error = $"Error when analyzing pdf file(s)."; - _logger.LogWarning($"{error} {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"{error}"); return error; } } diff --git a/src/Plugins/BotSharp.Plugin.Graph/GraphDb.cs b/src/Plugins/BotSharp.Plugin.Graph/GraphDb.cs index 99378ddc..ab6132dc 100644 --- a/src/Plugins/BotSharp.Plugin.Graph/GraphDb.cs +++ b/src/Plugins/BotSharp.Plugin.Graph/GraphDb.cs @@ -81,7 +81,7 @@ public class GraphDb : IGraphDb } catch (Exception ex) { - _logger.LogError($"Error when fetching Lessen GLM response (Endpoint: {url}). {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when fetching Lessen GLM response (Endpoint: {url})."); return result; } } diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/Functions/HandleHttpRequestFn.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/Functions/HandleHttpRequestFn.cs index f198c47c..4902af8e 100644 --- a/src/Plugins/BotSharp.Plugin.HttpHandler/Functions/HandleHttpRequestFn.cs +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/Functions/HandleHttpRequestFn.cs @@ -45,7 +45,7 @@ public class HandleHttpRequestFn : IFunctionCallback catch (Exception ex) { var msg = $"Fail when sending http request. Url: {url}, method: {method}, content: {content}"; - _logger.LogError($"{msg}\n(Error: {ex.Message}\r\n{ex.InnerException})"); + _logger.LogError(ex, $"{msg}"); message.Content = msg; return false; } diff --git a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Document.cs b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Document.cs index 8c49f48c..a2461f18 100644 --- a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Document.cs +++ b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Document.cs @@ -98,7 +98,7 @@ public partial class KnowledgeService } catch (Exception ex) { - _logger.LogError($"Error when processing knowledge file ({file.FileName}). {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when processing knowledge file ({file.FileName})."); failedFiles.Add(file.FileName); continue; } @@ -170,9 +170,7 @@ public partial class KnowledgeService } catch (Exception ex) { - _logger.LogWarning($"Error when importing doc content to knowledgebase ({collectionName}-{fileName})" + - $"\r\n{ex.Message}" + - $"\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when importing doc content to knowledgebase ({collectionName}-{fileName})"); return false; } } @@ -214,9 +212,8 @@ public partial class KnowledgeService } catch (Exception ex) { - _logger.LogWarning($"Error when deleting knowledge document " + - $"(Collection: {collectionName}, File id: {fileId})" + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when deleting knowledge document " + + $"(Collection: {collectionName}, File id: {fileId})"); return false; } } diff --git a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Graph.cs b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Graph.cs index 7c8f7168..dbbe8885 100644 --- a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Graph.cs +++ b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Graph.cs @@ -15,7 +15,7 @@ public partial class KnowledgeService } catch (Exception ex) { - _logger.LogWarning($"Error when searching graph knowledge (Query: {query}). {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when searching graph knowledge (Query: {query})."); return new GraphSearchResult(); } } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Crontab.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Crontab.cs index a40fc827..af10c373 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Crontab.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Crontab.cs @@ -26,7 +26,7 @@ public partial class MongoRepository } catch (Exception ex) { - _logger.LogError($"Error when saving crontab item: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when saving crontab item (agent id: {item.AgentId}, conv id: {item.ConversationId})."); return false; } } diff --git a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs index 60a79e6a..5c91301d 100644 --- a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs +++ b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs @@ -456,7 +456,7 @@ public class QdrantDb : IVectorDb } catch (Exception ex) { - _logger.LogError($"Error when downloading Qdrant snapshot (Endpoint: {url}, Snapshot: {snapshotFileName}). {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when downloading Qdrant snapshot (Endpoint: {url}, Snapshot: {snapshotFileName})."); return BinaryData.Empty; } } @@ -497,7 +497,7 @@ public class QdrantDb : IVectorDb } catch (Exception ex) { - _logger.LogError($"Error when uploading Qdrant snapshot (Endpoint: {url}, Snapshot: {snapshotFileName}). {ex.Message}\r\n{ex.InnerException}"); + _logger.LogError(ex, $"Error when uploading Qdrant snapshot (Endpoint: {url}, Snapshot: {snapshotFileName})."); return false; } } diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/GetTableDefinitionFn.cs b/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/GetTableDefinitionFn.cs index 4be73286..283620c9 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/GetTableDefinitionFn.cs +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/GetTableDefinitionFn.cs @@ -73,7 +73,7 @@ public class GetTableDefinitionFn : IFunctionCallback } catch (Exception ex) { - _logger.LogWarning($"Error when getting ddl statement of table {table}. {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting ddl statement of table {table}."); } } @@ -125,7 +125,7 @@ public class GetTableDefinitionFn : IFunctionCallback } catch (Exception ex) { - _logger.LogWarning($"Error when getting ddl statement of table {table}. {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting ddl statement of table {table}."); } } @@ -165,7 +165,7 @@ public class GetTableDefinitionFn : IFunctionCallback } catch (Exception ex) { - _logger.LogWarning($"Error when getting ddl statement of table {table}. {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting ddl statement of table {table}."); } } connection.Close(); diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs b/src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs index 40069494..57765ca7 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs @@ -82,8 +82,8 @@ public class DbKnowledgeService } catch (Exception ex) { - var note = $"Error processing table {table}: {ex.Message}\r\n{ex.InnerException}"; - _logger.LogWarning(note); + var note = $"Error processing table {table}."; + _logger.LogWarning(ex, note); } } diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/UtilFunctions/GetTableDefinitionFn.cs b/src/Plugins/BotSharp.Plugin.SqlDriver/UtilFunctions/GetTableDefinitionFn.cs index a4b493a3..3021e210 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/UtilFunctions/GetTableDefinitionFn.cs +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/UtilFunctions/GetTableDefinitionFn.cs @@ -67,7 +67,7 @@ public class GetTableDefinitionFn : IFunctionCallback } catch (Exception ex) { - _logger.LogWarning($"Error when getting ddl statement of table {table}. {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting ddl statement of table {table}."); } } @@ -119,7 +119,7 @@ public class GetTableDefinitionFn : IFunctionCallback } catch (Exception ex) { - _logger.LogWarning($"Error when getting ddl statement of table {table}. {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting ddl statement of table {table}."); } } @@ -159,7 +159,7 @@ public class GetTableDefinitionFn : IFunctionCallback } catch (Exception ex) { - _logger.LogWarning($"Error when getting ddl statement of table {table}. {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting ddl statement of table {table}."); } } connection.Close(); diff --git a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Audio.cs b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Audio.cs index ec1a4161..04b90a93 100644 --- a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Audio.cs +++ b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Audio.cs @@ -17,7 +17,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when saving speech file. {fileName} ({conversationId})\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving speech file. {fileName} (conv id: {conversationId})"); return false; } } diff --git a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Common.cs b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Common.cs index d21a4c1a..0659b0c8 100644 --- a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Common.cs +++ b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Common.cs @@ -20,7 +20,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when getting files: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting files (path: {relativePath})."); return Enumerable.Empty(); } } @@ -33,7 +33,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when getting file bytes: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting file bytes (url: {fileStorageUrl})."); return Array.Empty(); } } @@ -48,7 +48,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when saving file stream to path: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving file stream to path ({filePath})."); return false; } } @@ -63,7 +63,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when saving file bytes to path: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving file bytes to path ({filePath})."); return false; } } diff --git a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Conversation.cs b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Conversation.cs index 69cda8ca..4afec393 100644 --- a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Conversation.cs +++ b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Conversation.cs @@ -138,7 +138,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when saving message file {file.FileName}: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex,$"Error when saving message file {file.FileName} (conv id: {conversationId})."); continue; } } @@ -318,7 +318,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when getting message file screenshots {file} (messageId: {messageId}), Error: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when getting message file screenshots {file} (messageId: {messageId})."); return files; } } diff --git a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.KnowledgeBase.cs b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.KnowledgeBase.cs index d89da85b..4ae82e9e 100644 --- a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.KnowledgeBase.cs +++ b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.KnowledgeBase.cs @@ -25,9 +25,8 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when saving knowledge file " + - $"(Vector store provider: {vectorStoreProvider}, Collection: {collectionName}, File name: {fileName})." + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving knowledge file " + + $"(Vector store provider: {vectorStoreProvider}, Collection: {collectionName}, File name: {fileName})."); return false; } } @@ -107,8 +106,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when downloading collection file ({collectionName}-{vectorStoreProvider}-{fileId}-{fileName})" + - $"\r\n{ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when downloading collection file ({collectionName}-{vectorStoreProvider}-{fileId}-{fileName})"); return BinaryData.Empty; } } diff --git a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.User.cs b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.User.cs index d955342d..72076528 100644 --- a/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.User.cs +++ b/src/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.User.cs @@ -36,7 +36,7 @@ public partial class TencentCosService } catch (Exception ex) { - _logger.LogWarning($"Error when saving user avatar: {ex.Message}\r\n{ex.InnerException}"); + _logger.LogWarning(ex, $"Error when saving user avatar (user id: {_user.Id})."); return false; } }