Can cbsecurity be injected into a logbox appender?
# box-products
j
Can cbsecurity be injected into a logbox appender?
I've created a custom appender based on the ootb DBAppender and I tried adding
property name="cbSecurity" inject="@cbsecurity";
in it but it's not working... I feel like I'm missing something elementary here.
w
db appenders are not created by wirebox, so that might be your first problem
So cbsecurity is not very accessible directly from your custom appender. I don’t know what parts of cbsecurity you need in your appender, but if it is only your user info, it is quite easy. cbsecurity is setting your user info in the prc on every request, and since the AbstractAppender has a reference to coldbox you could access any variable present in the prc by calling
variables.coldbox.getRequestService().getContext().getPrivateValue()
. if you create your own preProcess interceptor you could save any var you want in your prc and access it from your own Appender. I described this process here: https://shiftinsert.nl/logbox-modify-your-message-format/
I was rethinking this strategy. Since there is a reference to coldbox I guess you might be able to do a
variables.coldbox.getWirebox.getInstance( "cbSecurity@cbSecurity" )
directly. I did not test it yet.
j
looks like that works!
👍 1
thanks!