Since the Hadoop ecosystem is basically Java-developed, log4j is often seen in many open source projects about big data processing.The purpose of this article is to make a basic description of its usage. 1. What is log4j?From the name of the log4j (log for Java) It is not difficult to see that it is a log library for Java. Specifically, it is an open source proje
1, what is log4j?
Log4j is an open source project for Apache, by using log4j, we can control the destination of log information delivery is console, file, GUI component, even interface server, NT Event recorder, UNIX syslog daemon, etc. We can also control the output format of each log, and by defining the level of each log information, we can control the log gen
I have said before about the major use of Java Log Tracking framework, also said, in fact, in which log4j plays a very important role. At present, most of the framework is also the use of log4j, although it has stopped the update, the author also re-logback the project, but Logback currently in the domestic use is quite small. Most of the current projects still use log4
In the selection of slf4j-api-1.7.7.jar + slf4j-log4j12-1.7.7.jar + log4j-1.2.17.jar output (the premise is that there is a corresponding configuration file log4j. properties, put in the root directory, usually SRC folder) to the file logs. log and errors. Log
1. The basic format is as follows:
# Configure root loggerlog4j. rootlogger = [level], appendername1, appendername2 ,... # Configure the log output
Log4j usage notes
Log4j is an open source project of Apache. By using log4j, programmers can control the destination of log information delivery, including the console, files, Gui components, and NT event recorder. They can also control the output format of each log, you can also define the level of each log to control the log generation process in greater detail
The website is about to be released. To track some logs, you need to use log4j. So I studied the configuration of log4j.
First, paste a configuration source file log4j. properties.
log4j.rootLogger=DEBUG, CONSOLE, FILE## for consolelog4j.appender.CONSOLE=org.apache.log4j.ConsoleAppenderlog4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayoutlog4j.appender.CO
Let's look back at the parameters.1InCCreate a new diskLog4jtest. Java,The content is as follows::Import org. Apache. commons. Logging. log;Import org. Apache. commons. Logging. logfactory;Public class log4jtest{Static log = logfactory. getlog (log4jtest. Class. getname ());Public static void main (string [] ARGs){Log.info ("I'm testing");Int x = 0;Try{X = 5/X;}Catch (exception E){Log.info (E );Log. debug (E );}}}
2CopyJarPackageCDiskLog4j-1.2.15.jarAndCommons-logging.jar)
Introduction
Log4j is an open-source project of Apache. By using log4j, we can control the log information delivery destination, such as the console, file, database, and even the interface server; you can also control the output format of each log. By defining the level of each log information, you can control the log generation process in greater detail.When necessary, you can use a con
1. Overview1.1 Backgroundin our daily development, logging is very important. Adding logging in an application in general, it is based on three purposes: monitoring the change of variables in the code, periodically recording to the file for other applications for statistical analysis work, tracking code run-time trajectory as the basis for future audits, as the role of the debugger in the integrated development environment, Debug information that prints code to a file or console.
1.2 Introducti
Exception Handling
2. Exception handling Experience 3.
Use of assertions
4.
logs in Java (JDK1.4 Logging Framework)
5. Third-party Log library (log4j, Commons Logging Framework)
5. Third-party log library (log4j,commons Logging Framework)
The official log framework JDK 1.4 Logging Framework is presented, followed by a description of the two Third-party log framework
Transferred from: http://www.blogjava.net/daiyongzhi/archive/2014/04/13/412364.htmlcommon-logging is a common log interface provided by Apache. The user is free to choose the third party's log component as a concrete implementation, like log4j, or the logging that comes with the JDK, common-logging will automatically find the log library that is actually used when the program runs by dynamic lookup mechanism. Of course, there is a simple logger implem
Common-loggingcommon-logging is a common log interface provided by Apache. The user is free to choose the third party's log component as a concrete implementation, like log4j, or the logging that comes with the JDK, common-logging will automatically find the log library that is actually used when the program runs by dynamic lookup mechanism. Of course, there is a simple logger implementation of common-logging inside, but the function is very weak. So
Logging naturally is very important, but I am afraid to remember slf4j and log4j, such as the configuration of the log framework is very few people, this thing is not difficult, but only after the configuration is rarely to move it, the development of new projects are usually copied from other projects, or reference to the documentNeedless to say, say log4j first, use l
Various exception information is inevitable during the operation of any system. to easily find the key to the problem, you need to create a log for the system to help analyze and find the problem, there are many methods to create logs. Here we will introduce one of the most popular methods. Logging, commons-logging, and log4 must be introduced. logging is a package that comes with JDK, while commons-logging is the abstraction of log4, we can use commons-logging or log4. Based on the idea of abst
Use of Java Standard log tool log4j (source code attached)
Source code Download
Log4j is the de facto Java standard logging tool. Is it possible to use log4j to a certain extent, it is a standard to measure whether a developer is a qualified Java programmer. If you're a Java programmer, if you're not using log4j, then
# -- Log4j. rootlogger: output the log information with the info level to the stdout and file destinations. The definitions of stdout and file can be named in the following code. Levels can be divided into off, fatal, error, warn, info, debug, and all. If off is configured, no information is displayed. If Info is configured, only info, warn is displayed, error Log information, while debug information is not displayed
Purpose:1. Write a fatal-level error to the 2000nt log2. Send email notification to administrators for warn, error, and fatal errors3. Other errors are output directly in the background.
Tutorial steps:Output to 2000nt log1. SetLog4jCopy the nteventlogappender. dll in the compressed package to the WINNT/system32 directory (PS: I will store it in the bin of Alibaba ATC)2. Write the configuration file log4j. properties.
# System log output in 2000Log4j.
Log4j Concise Manual
1. OverviewThis article describes the unique features of log4j APIs and its design principles. Log4j is an open source project based on many authors. It allows developers to control log output at any interval. It allows you to flexibly set runtime settings by setting an external configuration file. Most importantly,
A Brief introduction:
In order to better monitor the changes in the code and trace the trajectory of the code, while acting as a debugger in the development environment. The Apache Common Log Pack is an open source project for the Apache organization that provides developers with a wide range of common log nooplog interfaces. Users are free to select and implement a common log interface. The common log currently supports the following several logger:
1. LOG4
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.