AppMind™ and log4j 2 (12)
© Appmind Software AB 2002 All Rights Reserved.
AppMind™ and the AppMind Logo are trademarks of Appmind Software AB in Sweden, the United States and other countries. Other product
and company names mentioned herein are the trademarks and/or service marks of their respective owners. Nothing contained herein
should be construed as granting any license or right to use any trademark without the prior written permission of the party that owns the
trademark.
Classification: Public Information Document Id: 021001 Revision: A Date: 2002-09-19
Table of Contents
General.......................................................................................................................................... 2
Write a simple log4j program ..................................................................................................... 2
Configure your environment ..................................................................................................... 2
Implement the log4j example.................................................................................................... 3
Compile and run the log4j example.......................................................................................... 4
Integrate the simple log4j program with the AppMind framework ......................................... 4
Implement the appender class ................................................................................................. 4
Implement the layout class ....................................................................................................... 6
Add configuration for the layout and class ............................................................................... 7
Rerun the log4j example........................................................................................................... 7
Appendix A: AppMindAppender.java ........................................................................................ 9
General
Log4j is an open source project provided by the Jakarta Project (see [2]) and have many
similarities with the java.util.logging package introduced in J2SE 1.4. For example, one
of the features of log4j is the notion of inheritance in categories. By using a category hierarchy it
is possible to control whether a log statements should print or not. The category was in older
log4j versions represented by the class Category. However, the class Logger has replaced this
class since log4j version 1.2.
This document gives one suggestion of how to integrate log4j with AppMind by implementing an
appender and a layout class. The appender class is responsible for forwarding log events to the
AppMind framework. The layout class formats the incoming log event to a string before it is sent
to the AppMind framework.
Write a simple log4j program
Configure your environment
Before you start this tutorial, you need to install the following programs (preferably in the same
order as stated below):
1. Java 2 Platform, Standard Edition 1.3.1 (http://java.sun.com/j2se/1.3/download.html
)
2. Log4j, version 1.2 or later, (http://jakarta.apache.org/log4j/docs/download.html
)
3. AppMind Development Kit, version 3.2 or later
评论0