记录日志增加异常日志
This commit is contained in:
parent
5dddabe868
commit
2891a0d83b
|
@ -62,10 +62,12 @@ namespace Falcon.SugarApi.ApiDefinistions
|
|||
/// <typeparam name="TResponse">响应信息类型</typeparam>
|
||||
/// <param name="data">请求数据</param>
|
||||
/// <param name="result">响应数据</param>
|
||||
protected virtual void SaveLogger<TRequest, TResponse>(TRequest data, TResponse result) {
|
||||
/// <param name="exception">异常</param>
|
||||
protected virtual void SaveLogger<TRequest, TResponse>(TRequest data, TResponse result, Exception? exception = null) {
|
||||
var requestStr = this.JsonSerialize(data);
|
||||
var responseStr = this.JsonSerialize(result);
|
||||
var logmsg = $"{this.Prefix}\n请求消息:{requestStr}\n响应消息{responseStr}";
|
||||
var exStr = exception == null ? "" : exception.ToString();
|
||||
var logmsg = $"{this.Prefix}\n请求消息:{requestStr}\n响应消息:{responseStr}\n异常:{exStr}\n";
|
||||
this.Logger.LogInformation(logmsg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user