Hi Abp Team,
I'm using Blazor Web Assembly for UI, I would like to add some information from UI such as razor page name to know which page has called the api and some other information for tracking. How I can custom the Audit Logging module to add more information like that.
Thanks, Dharma (Han Nguyen)
10 Answer(s)
-
0
Hi,
This is just my simple idea:
- Add the current route name to the HttpRequest headers. for example:
public class AuditMessageHandler : DelegatingHandler, ITransientDependency { private readonly NavigationManager _navigationManager; public AuditMessageHandler(NavigationManager navigationManager) { _navigationManager = navigationManager; } protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { request.Headers.Add("blazor-audit-url", _navigationManager.Uri); return base.SendAsync(request, cancellationToken); } } public override void PreConfigureServices(ServiceConfigurationContext context) { PreConfigure<AbpHttpClientBuilderOptions>(options => { options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) => { clientBuilder.AddHttpMessageHandler<AuditMessageHandler>(); }); }); }
2 You can add your
AuditLogContributor
to save the information to the database.https://docs.abp.io/en/abp/latest/Audit-Logging#audit-log-contributors
-
0
Hi, I'd like to add some additional information into the standard ABP Audit Logging, for example with the standard audit logging of ABP will add one extra property such as PageName and when Audit Logging insert to database for Http Api call will add PageName into extra property of the logged record. When we check the log we will know exactly which page, which screen has called this api or related to this log record :
-
0
Hi,
I think I have explained it here.
https://support.abp.io/QA/Questions/6029#answer-3a0e6dda-91f6-3ffa-978d-a04fb88877c8
-
0
-
0
Thanks, let me try.
-
0
ok
-
0
I have done successful as you what you guide. Thank you so much
-
0
Hello Liangshiwei,
I'd like to reopen this ticket. I can add an extra property (blazor-url) into AuditLogging to keep blazor page url when calling Api. Now I'd like to get data from Auditlogging and can be filtered by blazor-url, for normal fields I can use AuditLogsAppService.GetListAsync(new GetAuditLogListDto { }) and filter but how can I apply filter for extra property such as blazor-url mentioned above?
Thanks
-
0
Hi,
You can override the AuditLogs repository to filter the
blazor-url
.You can refer to those:
- https://docs.abp.io/en/abp/latest/Entity-Framework-Core#mapefcoreproperty
- https://learn.microsoft.com/en-us/ef/core/modeling/shadow-properties#accessing-shadow-properties