如何设置AuditLog.CustomData字段? [英] How do I set the AuditLog.CustomData field?

查看:81
本文介绍了如何设置AuditLog.CustomData字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用aspnet样板,并且已经通过使用 [DisableAuditing] [Audited] 属性成功地精确修剪了哪些方法没有记录..因此,该部分工作得很好,并且我对我的日志记录级别感到满意.但是,我不明白如何有效地使用CustomData字段.我想使用此字段保存默认情况下未捕获的某些其他数据,但我不知道如何设置它或在哪里设置.预先感谢您的任何建议.

I'm using aspnet boilerplate and I've successfully trimmed down exactly which methods are/are not logged, by using the [DisableAuditing] and [Audited] attributes. So that part is working great, and I'm satisfied with my logging levels. However, I don't understand how to effectively use the CustomData field. I'd like to use this field to save certain additional data that is not captured by default, but I don't understand how to set it, or where. Thanks in advance for any advice.

推荐答案

您可以将 AuditingStore 子类化,并为数据设置 CustomData :

You can subclass AuditingStore and set CustomData to your data:

public class MyAuditingStore : AuditingStore
{
    public MyAuditingStore(IRepository<AuditLog, long> auditLogRepository)
        : base(auditLogRepository)
    {
    }

    public override Task SaveAsync(AuditInfo auditInfo)
    {
        auditInfo.CustomData = "certain additional data that is not captured by default";
        return base.SaveAsync(auditInfo);
    }
}

然后在模块中替换 IAuditingStore :

// using Abp.Configuration.Startup;

public override void PreInitialize()
{
    Configuration.ReplaceService<IAuditingStore, MyAuditingStore>(DependencyLifeStyle.Transient);
}

这篇关于如何设置AuditLog.CustomData字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆