How can we camunda generate logs using history service?

1,027 views
Skip to first unread message

bharat...@gmail.com

unread,
Sep 10, 2015, 4:41:12 PM9/10/15
to camunda BPM users
Can camunda generates logs at the same time while writing audit and full process information into history data tables?

Thanks,
Kumar

Philipp Ossler

unread,
Sep 11, 2015, 2:46:47 AM9/11/15
to camunda BPM users
Hi Kumar,

you can use a custom history backend to create logs additionally, see [1]. 
For example, you can extend the HistoryEventHandler to create the log entry and the data base entries, as default.

Greetings,
Philipp


bharat...@gmail.com

unread,
Sep 12, 2015, 6:25:28 PM9/12/15
to camunda BPM users, bharat...@gmail.com

Thanks Philipp for providing this information.

Could you please provide me an example to create log entry using history service?

Thanks
Kumar

bharat...@gmail.com

unread,
Sep 13, 2015, 11:14:59 PM9/13/15
to camunda BPM users
Hi Philipp,

i added historyeventhandler to applicationContext.xml file and running as shown below.

<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
<property name="processEngineName" value="default" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
<property name="historyEventHandler" ref="camundaHistoryEventHandler"/>
</bean>


<bean id="camundaHistoryEventHandler" class="org.att.wellsfargo.CamundaHistoryEventHandler"></bean>

But i think control is not coming to handleEvent or Handleevents method when starting a service

Could you please let me know about this.

Thanks
Kumar

Philipp Ossler

unread,
Sep 14, 2015, 1:56:30 AM9/14/15
to camunda-...@googlegroups.com
Hi Kumar,

a simple custom history event handler can look like this:

// extend the default history event handler to create log entries additionally
public class CustomHistoryEventHandler extends DbHistoryEventHandler implements HistoryEventHandler {

  // protected final static Logger LOGGER = ...

  @Override
  public void handleEvent(HistoryEvent historyEvent) {
    // create db entry
    super.handleEvent(historyEvent);

    // create log entry
    LOGGER.log(historyEvent);
  }
}


You have to register the history event handler in your configuration:
<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    <!-- ... -->
    <property name="history" value="audit" />  
    <property name="historyEventHandler" ref="customHistoryEventHandler" />
</bean>


When you execute a process instance then a db entry and a log entry should be created. Make sure that you set the history level in you configuration.

Greetings,
Philipp

bharat...@gmail.com

unread,
Sep 14, 2015, 10:25:52 AM9/14/15
to camunda BPM users
Thanks Philipp for providing this information and i able to generate logs using eventHandlers.

Thanks,
Bharath
Reply all
Reply to author
Forward
0 new messages