hello, Im using Grails 6.2.3 and was looking for a...
# questions
c
hello, Im using Grails 6.2.3 and was looking for an Audit solution. I came across the "Grails Audit Logging Plugin" which should suit what I want. I see I probably have to use version 4 of this. https://grails-plugins.github.io/grails-audit-logging-plugin/6.0.x/#description Anyone else using this? Any known caveats and/or alternatives wrt working with Grails 6 I should be aware of?
j
Both myself & @James Fredley use it extensively
l
I also have a Grails 6 app where I use v4 of it,,, works fine 👍🏻
j
I am using org.grails.pluginsaudit logging4.0.3 in Grails 6.2.3
c
Thanks, just added the Jar etc and had a look how it works, seems quite simple and very complete in what it's logging. One thing Im curious about is logging the actor who made a change, at the moment I see SYS, even though I made an update via the API as a logged in user. Is there info / ideas on how to capture the actor and log that in the audit table?
c
Hi @James Fredley Sorry to come back to this after so long. Been testing and I see we still have SYS as the actor in the DB log. Reading the docs, if using the SpringSecurity then the plugin "should" get the user from the context, I thought. I just have a simple setup, API and using SpringSecurity. The domain classes are being audited and I see the changes. Just the actor is not there. Did you implement a separate Bean to help do this maybe? I saw this was possible for custom code.
j
SYS will occur in instance where the controller is not directly processing the request. This happens with database migrations and can happen with scheduled jobs. Is that possibly the case? I'd look at https://grails-plugins.github.io/grails-audit-logging-plugin/6.0.x/#audit-request-resolvers and https://github.com/apache/grails-spring-security/issues/587 also
c
Hi James, I did read about that case re: scheduled job which makes sense. I think in the docs there is mention of a workaround. No the setup I have is Grails providing an API & SpringSecurity to an Angular FE. Users log in via Spring and can manage their data based on their role. The changes in data are captured correctly but the userId not
j
Are you using Async processing?
j
I'm at Convention Over Code and will try to take a look on Monday with a basis example app. I do have a lot of customization, but this should work out of the box as long as the request is being processed as the authenticated user via Spring Security.
👍 1
c
Hey James, with a fresh head I revisited the links you sent and tried some things myself. I have a working solution. It didn't work OOTB for me, I think in the docs they say SpringSecurity is default but didn't work. Even if I tried to set "SecurityContextHolder.MODE_THREADLOCAL" I implemented the AuditRequestResolver and pulled data from the SpringContext myself and this works for me. Not sure if this is what you have or something different?
j
That is good news. I think we may need to adjust the documentation. Before we do can you run your app with logging set to debug and see what logs you get when the app starts when it runs this: https://github.com/grails-plugins/grails-audit-logging-plugin/blob/0c1a35aed425deb[…]vy/grails/plugins/orm/auditable/AuditLoggingGrailsPlugin.groovy