-
1. Re: How log in BPM Script Task?
pschaefer May 11, 2015 7:58 AM (in response to mr.bee)If you want to output text to the console you can simply use
System.out.println("Hello World");
in your script task if you use Java as language. Depending on your server configuartion, the server will print this also to its server log.
-
2. Re: How log in BPM Script Task?
abhijithumbe May 12, 2015 12:30 AM (in response to mr.bee)Hi,
You can use slf4j/log4j API's in script task to capture logging as well. Foe this you have to declare project dependency on log4j.jar/slf4j.jar, like as:
~~~~
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
~~~~
Or you can upload log4j/slf4j jar into server repository and then specify project dependency on log4j.jar/slf4j.jar file.To upload log4j/slf4j jar into repository go to "Authoring-->Artifact repository-->upload"(specify groupid,artifactid & version if required).Then go to "Authoring"-->Project authoring-->Tools-->Project Editor-->Dependencies-->Add from Repository. Import 'org.apache.log4j.logger' in BPMN process and configure logging as per your requirement.
Hope it helps..
-
3. Re: How log in BPM Script Task?
mr.bee May 12, 2015 1:24 AM (in response to abhijithumbe)@Patrick i was already using the system.out.println(); that is working, but now want them to replace with some logging api. Either Log4j or jboss-logging.
@Abhijit you got my point, I don't have any issue with configuring the api. The confusion is how can i get the logger in script task. In script i cannot pass the class to logger.getLogger( class ) method because there is no class in my script.
Should i pass any string to get the logger using getLogger(String text) method?
I hope you understand my question.
-
4. Re: How log in BPM Script Task?
abhijithumbe May 12, 2015 2:18 AM (in response to mr.bee)Hi,
Yes, we have to use 'getLogger(String)' method. like as:
~~~~
Logger logger = null;
logger = Logger.getLogger("Logger");
logger.info("Process Name:-"+kcontext.getProcessInstance().getProcessName());
logger.info("Node Name:-"+kcontext.getNodeInstance().getNodeName())
~~~~
It will capture logging like as:
=============
11:26:33,995 INFO [Logger] (http-localhost.localdomain/127.0.0.1:8080-2) Process Name:-DemoProcess
11:26:33,995 INFO [Logger] (http-localhost.localdomain/127.0.0.1:8080-2) Node Name:-Script Task
11:26:33,995 INFO [Logger] (http-localhost.localdomain/127.0.0.1:8080-2) Process InstanceID=8
=============
So its really difficult to track logging when we you have multiple process instances running with multiple script tasks. So I will suggest to create logger object like as:
~~~~
Logger logger = null;
logger = Logger.getLogger(kcontext.getProcessInstance().getProcessName()+"|"+kcontext.getNodeInstance().getNodeName()+"|"+kcontext.getProcessInstance().getId());
~~~~
It will capture logging like as:
=============
11:32:46,174 INFO [DemoProcess|Script Task|10] (http-localhost.localdomain/127.0.0.1:8080-1) Process Name:-DemoProcess
. .
=============
With this logging you can easily check processName,NodeName and ProcessInstanceId.
Hope it helps..