You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
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
The text was updated successfully, but these errors were encountered:
@selvakumar-arc this has nothing to do with Orleans, its the c# compiler telling you that you have errors in your code, but here is the correct version if you want to use it:
public partial record GetMyCalculation(MyRequest request, ILogger logger) : BaseCalculation
{
public override MyResponse Calculate()
{
MyResponse response = new MyResponse();
try
{
LogErrors(logger, "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}.")]
static partial void LogErrors(ILogger logger, string message);
}
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();
}
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();
}
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
The text was updated successfully, but these errors were encountered: