Configuring Flux with Log4j

VERSION 2 Published

Created on: 09-Nov-2007 09:17 by flux - Last Modified:  26-Feb-2008 16:11 by Guest

So, you want to configure Flux to run with Log4j. The following guide will go through the steps of configuring Flux with Log4j. The first section deals with configuring Flux through your Flux engine configuration file (.fec), while the second section deals with configuring Flux through the Configuration object in code.

Configuring Log4j with the Flux engine configuration file (.fec):


To configure logging, follow these steps:

  • Add the log4j-1.2.7.jar to your engine's class path.
  • Create a log4j.properties file.
  • Add the following line to your engines startup, replacing the path/to/properties/file with the correct path. You will want to place this after the -Xmx512m entry in your engine startup script.
-Dlog4j.configuration=file:///path/to/properties/file/log4j.properties


  • Next, you will have to configure the Flux engine to use a new logger. To do this, add the following line to your engine configuration file (.fec):
logger_type=log4j


  • Now you have to make a decision, do you want do configure Flux to use a single log file or multiple log files. The following will guide you through both steps.

Configuring Flux to use a single log4j file:

  • In your log4j.properties file add the following:
log4j.rootLogger=DEBUG, RootLoggerAppender
log4j.appender.RootLoggerAppender=org.apache.log4j.RollingFileAppender
log4j.appender.RootLoggerAppender.MaxFileSize=20MB
log4j.appender.RootLoggerAppender.MaxBackupIndex=10
log4j.appender.RootLoggerAppender.File=flux.log
log4j.appender.RootLoggerAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.RootLoggerAppender.layout.ConversionPattern=%d %-4r %-5p [%t] \t\t%c %3x - %m%n

Configuring Flux to use multiple log4j files:

  • Add the flowing to your Flux engine configuration (.fec):
CLIENT_LOGGER=FluxClient
FLOW_CHART_LOGGER=FluxJob
SYSTEM_LOGGER=FluxSystem 
AUDIT_TRAIL_LOGGER=FluxAuditTrail

  • In your log4j.properties file add the following:
log4j.rootLogger=INFO, RootLoggerAppender
log4j.logger.client=INFO,ClientAppender
log4j.logger.audit_trail=INFO,AuditTrailAppender
log4j.logger.flow_chart=INFO,FlowChartAppender
log4j.appender.RootLoggerAppender=org.apache.log4j.RollingFileAppender
log4j.appender.RootLoggerAppender.MaxFileSize=5MB
log4j.appender.RootLoggerAppender.MaxBackupIndex=10
log4j.appender.RootLoggerAppender.File=flux.log
log4j.appender.ClientAppender=org.apache.log4j.RollingFileAppender
log4j.appender.ClientAppender.MaxFileSize=5MB
log4j.appender.ClientAppender.MaxBackupIndex=10
log4j.appender.ClientAppender.File=fluxClient.log
log4j.appender.AuditTrailAppender=org.apache.log4j.RollingFileAppender
log4j.appender.AuditTrailAppender.MaxFileSize=5MB
log4j.appender.AuditTrailAppender.MaxBackupIndex=10 
log4j.appender.AuditTrailAppender.File=fluxAuditTrail.log
log4j.appender.FlowChartAppender=org.apache.log4j.RollingFileAppender
log4j.appender.FlowChartAppender.MaxFileSize=5MB
log4j.appender.FlowChartAppender.MaxBackupIndex=10
log4j.appender.FlowChartAppender.File=fluxFlowChart.log
log4j.appender.RootLoggerAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ClientAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.AuditTrailAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.FlowChartAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.RootLoggerAppender.layout.ConversionPattern=%d %-4r %-5p [%t] %37c %3x - %m%n
log4j.appender.ClientAppender.layout.ConversionPattern=%d %-4r %-5p [%t] %37c %3x - %m%n
log4j.appender.AuditTrailAppender.layout.ConversionPattern=%d %-4r %-5p [%t] %37c %3x - %m%n
log4j.appender.FlowChartAppender.layout.ConversionPattern=%d %-4r %-5p [%t] %37c %3x - %m%n


  • Now you have configured Flux to use Log4j through your Flux engine configuration file (.fec).

Configuring logging with Log4j through code

To configure logging follow these steps:
  • Import the log4j-1.2.7.jar in your Java class.
  • Create a log4j.properties file.
  • Use the following option when running your Java class, replacing the path/to/properties/file with the correct path.
-Dlog4j.configuration=file:///path/to/properties/file/log4j.properties

  • Next, you will have to configure the Flux engine to use a new logger. To do this, add the following configuration option to your engine configuration.
Set loggerTypes = new HashSet();
loggerTypes.add(LoggerType.LOG4J);
config.setLoggerTypes(loggerTypes); 

  • You have two choices when configuring Flux to work with Log4j. You can either configure Flux to log to a single log file, or to multiple log files. h2. Configuring Flux to use a single log4j file:
  • Add the same configuration options that the single log file used above to your log4j.properties file.

Configuring Flux to use multiple log4j files:

  • Add the following to your Flux engine configuration
config.setClientLogger("FluxClient");
config.setFlowChartLogger("FluxJob");
config.setSystemLogger("FluxSystem");
config.setAuditTrailLogger("FluxAuditTrail"); 

  • Add the same log4j configuration options for multiple logs files used above to your log4j.properties file. Now you have configured Flux to use Log4j through code.
Average User Rating
(0 ratings)




There are no comments on this document