About the Example Application

This Short Cut is going to be filled with examples; lots of examples. As noted earlier, this Short Cut also comes with an Example Application (available at the code example repository), and every example in this Short Cut (except where explicitly noted) comes straight from it. That way you can go right from here to the example, see the full code and configuration, and run it. You can match up the example number from here to the build target to execute. The configuration files (log4j.properties, for example) will be copied to the PROJECT_ROOT/target/classes directory, where PROJECT_ROOT is the full path to the directory where you installed the sample code. In all examples - unless otherwise noted - the PROJECT_ROOT folder is C:\home\workspace\log4j-example on Windows and ~/workspace/log4j-example on Linux.

I have kept the Example Application simple so that you don’t spend time learning how the application works, and can focus your efforts on learning how it uses log4j (Figure 1 illustrates the Example application architecture). The application is a simple, standalone Supplier/Consumer application. One or more Supplier threads do “work” (via the WorkUnit class), place an item into a Queue, where one or more Consumer threads similarly do “work.”

Example application architecture: Through JMX a web browser is used to manage and monitor the application as it runs.

Figure 1. Example application architecture: Through JMX a web browser is used to manage and monitor the application ...

Get Log4J now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.