Problem Description
Logging in TIBCO BW designer is not as flexible as java.
In TIBCO designer the logging activity is done using Write to Log activity which writes logs to a particular file. Configuring that logging part is not as flexible as in java projects.
Solution Description
This component is implementing log4j in TIBCO designer by using a java activity. This java activity will take location of log4j file as input. The log4j file can be configured with changing the deployed BW on the administrator thus making it flexible enough as its there in java projects. This project can be further extended to take different types of inputs. Currently, this code takes the information to be logged as input which can be further modified to take different inputs like log level and other important information to be logged. In the present code the log file log4j.xml needs to be present at:D:/logs/log4j.xml and a read file activity is used to read the information to be logged. The location of both these files can be changed and the code can be run on machines.
Prerequisites for running the project:
1. TIBCO BW and designer must be installed on machine.
2. log4j.jar should be present at the location: <TIBCO_Home>/bw/<version>/lib
Code :
package Test.Log4j;
import java.util.*;
import java.io.*;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
public class Log4jLog4jCode{
/****** START SET/GET METHOD, DO NOT MODIFY *****/
protected String Log4jLocation = “”;
protected String Application_id = “”;
protected String Log_Level = “”;
protected String LogInfo = “”;
public String getLog4jLocation() {
return Log4jLocation;
}
public void setLog4jLocation(String val) {
Log4jLocation = val;
}
public String getApplication_id() {
return Application_id;
}
public void setApplication_id(String val) {
Application_id = val;
}
public String getLog_Level() {
return Log_Level;
}
public void setLog_Level(String val) {
Log_Level = val;
}
public String getLogInfo() {
return LogInfo;
}
public void setLogInfo(String val) {
LogInfo = val;
}
/****** END SET/GET METHOD, DO NOT MODIFY *****/
public Log4jLog4jCode() {
}
public void invoke() throws Exception {
/* Available Variables: DO NOT MODIFY
In : String Log4jLocation
In : String Application_id
In : String Log_Level
In : String LogInfo
* Available Variables: DO NOT MODIFY *****/
System.out.println(“***************************1″);
Logger logger = Logger.getLogger(“Log4jLog4jCode.class”);
System.out.println(“***************************2″);
DOMConfigurator.configure(“D:/logs/log4j.xml”);
logger.debug(“Here is some DEBUG”);
logger.info(“Here is some INFO”);
logger.warn(“Here is some WARN”);
logger.error(“Here is some ERROR”);
logger.fatal(“Here is some FATAL”);
logger.debug(“Application_id”);
}
}
For training on TIBCO BusinessWorks mail us at [email protected]