|
Log4j in JCAPS |
|
Following is the Steps to implementation the log4j in JCAPS
Step 1:
Import the log4j jar file in to your Project by
Right click on the project select - > import then -> file we chose the
-> jar file (log4j) and select import.
Step 2:
Then import the jar file into your JCD where you want to implement the
log4j is by
Click on Import JAR file on JCD console -> Add ->and select the jar
file that had been imported into you project.
Step 3:
Then code import command statement in the JCD.
import org.apache.log4j.*;
Step 4:
Declare the object for the logger before the main method, as below.
static Category logger = Category.getInstance( "" );
Step 5:
In the Main method code specific path and the log4j properties file, as bel
ow.
PropertyConfigurator.configure( "" );
Step 6:
See that you had configured the log4j property file; your log4j should
look like this
log4j.category.jcdManesh=INFO,dest1
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.File=C:/Properties/InstJava.log
log4j.appender.dest1.MaxFileSize=10MB
log4j.appender.dest1.MaxBackupIndex=1
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
Sample implementation of the log4j JCD looks like this
Code:
package Project1;
import org.apache.log4j.*;
public class jcdManesh
{
static Category logger = Category.getInstance( "jcdManesh" );
public com.stc.codegen.util.CollaborationContext collabContext;
public com.stc.codegen.util.TypeConverter typeConverter;
public void receive( com.stc.connector.appconn.file.FileTextMessage inp
ut )
throws Throwable
{
PropertyConfigurator.configure(
"C:/JavaCAPS513/logicalhost/log4j.properties" );
logger.info( ">>>>>> START <<<<<<" ); logger.info( ">>>>>> END <<<<<<" ); } }
Sample log4j.properties for the above JCD looks like this
Code:
log4j.category.jcdManesh=INFO,dest1
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.File=C:/Properties/InstJava.log
log4j.appender.dest1.MaxFileSize=10MB
log4j.appender.dest1.MaxBackupIndex=1
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
Note: You can download the Log4J from the following website:
http://logging.apache.org/log4j/1.2/download.htmlLabels: java caps, Log4J, Log4j in JCAPS, Logging, Monitoring |
 |
|
|
|
Manesh Abhimanyu |
Manesh is a Sr. EAI Consultant, at present working in Singapore (Little Red Dot).
His focus is in the areas of SOA, ESB and Enterprise Architecture Management.
Contact him via email (mak2powerATyahoo.co.in)
|
Menu |
|
Archives |
|
Links |
|
Website developed & maintained by |
Manesh
Abhimanyu K. (Mak)
Click here to contact Manesh
 |
|