Skip to content

Building and Configuring Blitz4j

Jae Hyeon Bae edited this page Dec 3, 2013 · 3 revisions

Getting Blitz4j Binaries

You have the following choices to get the blitz4j binaries. Always try to get the latest release as tend to have more fixes.

 <dependency>
  <groupId>com.netflix.blitz4j</groupId>
  <artifactId>blitz4j</artifactId>
  <version>1.1.11</version>
 </dependency>
  • You can build the binaries from the source by pulling the source and running

./gradlew clean build

The binaries will be built under ./build/libs.

Configuring Blitz4j

The first thing you need to do is to put the blitz4j-xxx.jar in your application classpath. You can now configure blitz4j by first initializing the Logging Configuration as follows.

LoggingConfiguration.getInstance().configure()

or

LoggingConfiguration.getInstance().configure(Properties props)

If you have any overriding log4j configuration, you can pass them as properties to the above initialization. Additionally, this initialization searches for log4j.properties in your classpath and initializes log4j.

Any appenders you might want to covert to an asynchronous appender should be configured by the property below.

log4j.logger.asyncAppenders=INFO,MYAPPENDER

where the level INFO does not bear any significance and is used for the sake of log4j being able to identify this as a configuration. MYAPPENDER should be a valid appender name that you want to convert automatically to an asynchronous appender.

Advanced Configurations can be defined as specified here.

Now, any calls going through log4j would go through Blitz4j and the asynchronous appender. If you have configured a PatternLayout to generate the location information of the caller, you can squeeze some performance using NFPatternLayout.

Finally, when shutting down the application, you may want to call

LoggingConfiguration.getInstance().stop()

The above flushes the events from the in-memory buffer before the application shuts down.

For more detailed examples, please refer to the test cases here.