Log4j

Log4j

Infobox Software
name = Apache log4j



caption =
developer = Apache Software Foundation
latest release version = 1.2.15
latest release date = release date|2007|09|29
latest preview version =
latest preview date =
operating system = Cross-platform
programming language = Java
genre = Logging Tool
license = Apache License 2.0
website = [http://logging.apache.org/log4j logging.apache.org/log4j]
Apache log4j is a Java-based logging utility. It was originally written by Ceki Gülcü and is now a project of the Apache Software Foundation. It is used primarily as a debugging tool. log4j is one of several Java Logging Frameworks.

Ceki Gülcü has since started the SLF4J [http://www.slf4j.org/] and [http://logback.qos.ch/ Logback] projects, with the intention of offering a compatible successor to log4j.

Log Level

The following table defines the log levels and messages in Log4j, in decreasing order of severity. The left column lists the log level designation in Log4j and the right column provides a brief description of each log level.

Configuration

There are two ways to configure log4j. One is with a properties file and the other is with an XML file. Within either you can define 3 main components: Loggers, Appenders and Layouts. Configuring logging via a file has the advantage of turning logging on or off without modifying the application that uses log4j. The application can be allowed to run with logging off until there's a problem, for example, and then logging can be turned back on simply by modifying the configuration file.

Loggers are logical log file names. They are the names that are known to the Java application. Each logger is independently configurable as to what level of logging (FATAL, ERROR, etc) it currently logs. In early versions of log4j, these were called category and priority, but now they're called logger and level, respectively.

The actual outputs are done by Appenders. There are numerous Appenders available, with descriptive names, such as FileAppender, ConsoleAppender, SocketAppender, SyslogAppender, NTEventLogAppender and even SMTPAppender. Multiple Appenders can be attached to any Logger, so it's possible to log the same information to a file locally and to a socket listener on another computer, for example.

Appenders use Layouts to format log entries. A popular way to format one-line-at-a-time log files is PatternLayout, which uses a pattern string, much like the C / C++ function printf. There are also HTMLLayout and XMLLayout formatters for use when HTML or XML formats are more convenient, respectively.

Example

Log viewer

Apache has another project named Chainsaw which was intended to use log4j generated log files. Chainsaw is a java-based GUI viewer with a lot of functionality. Chainsaw also uses similar configuration file as log4j. Other log viewing tools can be used with log4j too, for example [http://log2web.sf.net/ log2web] , which is opensource and web-based, but has fewer features than Chainsaw, or [http://www.logmx.com LogMX] , which is a commercial log viewer including more features than Chainsaw (even in the free evaluation version).

See also

*SLF4J
*Chainsaw

External links

* [http://logging.apache.org/log4j/1.2/manual.html Short introduction to log4j]
* [http://logging.apache.org/log4j/ Official log4j Homepage]
* [http://logging.apache.org/log4j/docs/api/index.html log4j Javadocs]
* [http://timarcher.com/?q=node/10 Setting up a log4j Socket Server to Email You Errors From Your Java Programs]
* [http://www.logmx.com LogMX: a commercial, log4j file viewer]

Ports

* [http://code.google.com/p/log5j/ log5j] - A 'modern' log4j that supports printf and has additional performance features.
* [http://dclib.sourceforge.net/ dlib C++ library Homepage] - A port for C++
* [http://logging.apache.org/log4cxx/ Log4cxx Homepage] - apache port for C++
* [http://log4cplus.sourceforge.net/ Log4cplus Homepage] - Another port for C++ (outdated)
* [http://log4cpp.sourceforge.net/ Log4cpp Homepage] - Yet another port for C++ (outdated)
* [http://log4plsql.sourceforge.net/ Log4plsql HomePage] ] - A port to the Oracle PL/SQL
* Log4c - A port for C
* [http://log4perl.sourceforge.net/ Log4perl] - A port for Perl
* log4js - A port for JavaScript
* [http://docs.python.org/lib/module-logging.html logging] - The official logging module for Python inspired by log4j.
* [http://log4r.sourceforge.net Log4r] - Ruby logging module inspired by log4j
* Log4net - A port to the Microsoft .NET Framework
* [http://logging.apache.org/log4php/ log4php] a port for PHP
* [http://logback.qos.ch logback] a purported successor to log4j, designed by log4j's founder
* [http://www.forestent.com/wiki/Log4sh:Main_Page log4sh] a port for various Unix shells including sh, bash, dash and ksh
* [http://sourceforge.net/projects/log4cocoa/ Log4Cocoa] - A Port for Cocoa
* [http://sourceforge.net/projects/log4d/ Log4D] - A Port for Delphi


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • log4j — Maintainer Ceki Gülcü, C. Arnold Entwickler Apache Software Foundation Aktuelle Version 1.2.16 (6. April 2010) Betriebssystem plattformunabhängig …   Deutsch Wikipedia

  • Log4J — ist ein Framework zum Loggen von Anwendungsmeldungen in Java. Es wird von unzähligen Open Source als auch kommerziellen Softwareprodukten verwendet und hat sich als De facto Standard etabliert. Das Projekt wurde von Ceki Gülcü während seiner… …   Deutsch Wikipedia

  • Log4j — ist ein Framework zum Loggen von Anwendungsmeldungen in Java. Es wird von unzähligen Open Source als auch kommerziellen Softwareprodukten verwendet und hat sich als De facto Standard etabliert. Das Projekt wurde von Ceki Gülcü während seiner… …   Deutsch Wikipedia

  • Log4j — Apache log4j Desarrollador Apache Software Foundation http://logging.apache.org/log4j Información general Última versión estable 1.2.16 …   Wikipedia Español

  • Log4j — Apache log4j Тип Журналирование Разработчик Apache Software Foundation Написана на Java Операционная система Кроссплатформенное ПО Последняя версия 1.2.16 (6 апреля 2010) …   Википедия

  • Log4J — Apache Jakarta Jakarta est un ensemble de projets de logiciels libres, écrits en langage Java, développés par la fondation Apache de manière collaborative et consensuelle et tous publié sous licence Apache. Sous projets Les sous projets Jakarta… …   Wikipédia en Français

  • Log4net — log4j ist ein Framework zum Loggen von Anwendungsmeldungen in Java. Es wird von unzähligen Open Source als auch kommerziellen Softwareprodukten verwendet und hat sich als De facto Standard etabliert. Das Projekt wurde von Ceki Gülcü während… …   Deutsch Wikipedia

  • Java logging frameworks — multipleissues refimprove = June 2008 OR = June 2008 copyedit = June 2008Java logging frameworks are computer data logging packages for the Java platform.Logging is a common issue for most development teams. There have been several frameworks… …   Wikipedia

  • TTCC — [http://logging.apache.org/log4j/docs/api/org/apache/log4j/TTCCLayout.html TTCC] is a message format used by Log4j. TTCC is acronym for Time Thread Category Component . It uses the following pattern: %r [%t] % 5p %c %x %m WhereExample output 467… …   Wikipedia

  • Ceki Gülcü — is the founder of the log4j project and the author of [http://www.qos.ch/shop//products/log4j/log4j Manual.jsp The complete log4j manual ] . Ceki has since started the SLF4J and Logback projects, with the intention of offering a compatible… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”