eventhorizon-cli opened a new issue, #594:
URL: https://github.com/apache/rocketmq-clients/issues/594

   ### Programming Language of the Client
   
   C#
   
   ### Is Your Feature Request Related to a Problem?
   
   The logs of csharp client are written to files by default, and cannot be 
written only to the console, this is not very friendly to the .net developers.
   
   1. This kind of logging is not in line with the normal practice of .NET 
developers.
   2. If it is a product environment, long-term log file squeezes can cause 
certain issues.
   3. The control of log output is not flexible enough.
   
   
   ### Describe the Solution You'd Like
   
   The more commonly used logging system in .net sdk is  
Microsoft.Extensions.Logging.
   
https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line
   
   The sdk can expose an API for configuring LoggerFactory, allowing users to 
configure it freely.
   
   The design of EF Core can be referenced.
   
https://learn.microsoft.com/en-us/ef/core/logging-events-diagnostics/extensions-logging?tabs=v3#other-application-types
   
   I tried to modify the logger in rocketmq client. Here is what it looks like 
after modification.
   
   ```C#
   public static class MqLogManager
   {
       private static ILoggerFactory _loggerFactory;
   
       public static ILogger<T> CreateLogger<T>()
       {
           return _loggerFactory?.CreateLogger<T>() ?? NullLogger<T>.Instance;
       }
       
       public static ILogger CreateLogger(string categoryName)
       {
           return _loggerFactory?.CreateLogger(categoryName) ?? 
NullLogger.Instance;
       }
   
       public static void UseLoggerFactory(ILoggerFactory loggerFactory)
       {
           _loggerFactory = loggerFactory ?? throw new 
ArgumentNullException(nameof(loggerFactory));
       }
   }
   ```
   
   usages:
   
   ```C#
   MqLogManager.UseLoggerFactory(LoggerFactory.Create(builder =>
   {
       builder.AddConsole();
   }));
   
   public abstract class Client
   {
       private static readonly ILogger Logger = 
MqLogManager.CreateLogger<Client>();
   
       protected virtual async Task Start()
       {
           Logger.LogDebug($"Begin to start the rocketmq client, 
clientId={ClientId}");
       }
   }
   ```
   
   If possible, I would like to submit a PR, thanks.
   
   ### Describe Alternatives You've Considered
   
   Modify the current nlog code to provide the option not to output to a file
   
   ### Additional Context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to