Exposing log service/func to be used by nodes and edges listeners

Hey

What would be the best approach to expose a service / function for nodes and edges to perform logging via listeners?

I’d like to be able to put an expression such ${log('hello')} on nodes listeners and edges which will call some method that will just perform the logging via slf4j,

I’m using the standard Tomcat bundle,

Thanks.

Hi @Asaf_Shakarzy,

maybe you could just add this log level to your configuration:

name="org.camunda.bpm.engine.bpmn.behavior" level="debug"

Hope this helps,

Ingo

I want to have my own logs that are more business rather dump technical transitions details

Hi @Asaf_Shakarzy,

if you have Spring in your setup, you can add a Bean (https://docs.camunda.org/manual/7.9/user-guide/process-engine/expression-language/#external-context-variables-with-spring-and-cdi) to log and use this in listeners. (https://docs.camunda.org/manual/7.9/user-guide/process-engine/delegation-code/#execution-listener)

Hope this helps,

Ingo

@Ingo_Richtsmeier

yea i came across Spring but I guess the standard bundle comes without Spring setup and I was finding it too complicated to setup just for a single log bean.

I this or CDI are the only ways to expose a bean?

Thanks

They are the easiest one. You can find a configuration for spring in a shared engine in the getting started guide: https://docs.camunda.org/get-started/spring/shared-process-engine/. Have a look into the other chapters to understand, what’s going on in the project.

A more theoretical option is to configure the expressionManager in the engine to the org.camunda.bpm.engine.test.mock.MockExpressionManager. Then you can use Mocks.register(key, value) to add certain values (or classes). But this is invented for unit tests and not for production environment.

Cheers, Ingo

Pity there’s no simple way to bind a function to the EL resolver,

Alright then :slight_smile:, thanks a lot Ingo !

for those who’s seeking such solution,

I found an easy way (without going through dependency injection magics) that works both for nodes & edges by using a Java Class listener that performs the Logging while messages are set by field injection.

Take a look at this: https://github.com/DigitalState/camunda-coverage-generation-groovy/blob/master/src/main/groovy/io/digitalstate/camunda/coverage/bpmn/SequenceFlowHistory.groovy

And

You can covert the js into a java delegate if you wanted and just add the delegate to each sequence flow as a listener