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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.