Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use IAuditingConfiguration.IsEnable property to totaly disable audit function #721

Closed
dukecheng opened this issue Nov 26, 2015 · 11 comments

Comments

@dukecheng
Copy link

In the AbpBootstrapper.Initialize(); it will register the IAuditingConfiguration and also will init the AuditingRegister, in the registor, it will use the IAuditingConfiguration.IsEnable value, so my question is does have any chance that allow me to set the IAuditingConfiguration.IsEnable In my application?

@hikalkan
Copy link
Member

It's enabled by default. Use this code to disable it:

Configuration.Auditing.IsEnabled = false;

This code should be in PreInitialize method of your module.

@dukecheng
Copy link
Author

Thanks for your reply, I see this Used in the AbpKernelModule PreInitialize() method, but as I know the AbpKernelModule is the top module, I think my module's PreInitialize method woudn't run before the AbpKeneralModule's PreInitialize method, How do you think?

@hikalkan
Copy link
Member

AbpKernelModule runs first since all modules depend on it (http://www.aspnetboilerplate.com/Pages/Documents/Module-System#DocModuleLifecycleEvents)

@dukecheng
Copy link
Author

As your Lifecycle said, If i have a custome Module called MyModule that DependsOn AbpKernalModule, Before MyModule's PreInitialize method call, the AbpKernelModule's PreInitalize already executed, So If I added the code
Configuration.Auditing.IsEnabled = false;
into MyModule's PreInitialize method, it will not make effect.

@hikalkan
Copy link
Member

Hi,

As you can see, AbpKernelModule has not a code that enabled/disables AuditLogging: https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/AbpKernelModule.cs#L31
It's enabled in the config as default: https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/Auditing/AuditingConfiguration.cs#L15

So, your module's PreInitialize runs after AbpKernelModule's preinitialize and disables it.

Please try it, it will work ;)

@dukecheng
Copy link
Author

AbpKernelModule
=> public override void PreInitialize() [AbpKernelModule.cs line 28]
=> AuditingInterceptorRegistrar.Initialize(IocManager); [AbpKernelModule.cs line 35]
=> public static void Initialize(IIocManager iocManager) [AuditingInterceptorRegistrar.cs line 13]
=> if (!_auditingConfiguration.IsEnabled) [AuditingInterceptorRegistrar.cs line 14]

@hikalkan
Copy link
Member

OK, I now see. AuditingInterceptor was checking IsEnabled before, but I removed it.
Thank you for the bug report.

@hikalkan hikalkan added this to the ABP v0.7.5 milestone Nov 26, 2015
@hikalkan hikalkan added bug and removed question labels Nov 26, 2015
@dukecheng
Copy link
Author

Hope we can got fixed version quickly! :):)

@hikalkan
Copy link
Member

Hi,

Did you try it?

Because, https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/Auditing/AuditingInterceptor.cs#L43 checks before every audit logging. And https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/Auditing/AuditingHelper.cs#L11 checks IsEnabled.

So, IsEnabled is also checked for every audit logging.

@dukecheng
Copy link
Author

@hikalkan
Copy link
Member

Yes, I think so. But at least it works as expected. (added a unit test shows it works: 6edbe5b)
I will refactor it to be reasonable.
Thanks.

@hikalkan hikalkan modified the milestones: ABP v0.8.0, ABP v0.7.5 Nov 26, 2015
@hikalkan hikalkan reopened this Dec 2, 2015
@hikalkan hikalkan modified the milestones: ABP v0.9.0, ABP v0.8.0 Jan 9, 2016
@hikalkan hikalkan modified the milestones: v0.12.0, v0.10.0 Jun 30, 2016
@hikalkan hikalkan modified the milestones: v0.12.0, v1.0.0 Aug 22, 2016
@hikalkan hikalkan removed this from the v0.12.0 milestone Aug 22, 2016
@hikalkan hikalkan modified the milestones: v1.0.0, v0.13.0 Sep 10, 2016
@hikalkan hikalkan removed this from the v0.13.0 milestone Sep 20, 2016
KenProDev pushed a commit to KenProDev/aspnetboilerplate that referenced this issue Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants