Microsoft Orleans - Logging for Record type
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 13h 56m
- Merged PRs (30d)
- 351
Description
Hi,
I am trying to implement logging to Microsoft Orleans (new to Orleans) project but getting error. Please help me how to implement logging. Attaching my sample code for reference.
**Option 1**
public record GetMyCalculation(MyRequest request, ILogger logger) : BaseCalculation
{
public override MyResponse Calculate()
{
MyResponse response = new MyResponse();
try
{
logger.LogError("errrrrorrr");
response.IsSuccess = true;
response.Message = "Success!";
}
catch (Exception ex)
{
response.IsSuccess = false;
response.Message = ex.Message;
}
return response;
}
}
Getitng error - Error (active) CA1848 For improved performance, use the LoggerMessage delegates.
**Option 2**
public record GetMyCalculation(MyRequest request, ILogger logger) : BaseCalculation
{
public override MyResponse Calculate()
{
MyResponse response = new MyResponse();
try
{
LogErrors("errrrrorrr");
response.IsSuccess = true;
response.Message = "Success!";
}
catch (Exception ex)
{
response.IsSuccess = false;
response.Message = ex.Message;
}
return response;
}
[LoggerMessage(LogLevel.Error, Message = "There was an error occurred in Calculation. {message}.")]
public partial void LogErrors(string message);
}
Getting error like
Error (active) CS8795 Partial method 'GetMyCalculation.LogErrors(string)' must have an implementation part because it has accessibility modifiers.
Error (active) CA1822 Members that do not access instance data or call instance methods can be marked as static. After you mark the methods as static, the compiler will emit nonvirtual call sites to these members. This can give you a measurable performance gain for performance-sensitive code.
Thank you!
Selvakumar R
Contributor guide
Research direction
Start by reproducing the two record-based logging examples from the issue in a Microsoft Orleans application and inspect the reported CA1848, CS8795, and CA1822 diagnostics. Determine whether the behavior is an Orleans-specific problem or standard C# logging guidance; done means documenting or correcting the supported approach so the sample compiles without these errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100