Log4j logs and log4j logs
First, AOP is required to process logs. it is inconvenient to process logs without using AOP.
Log processing is a very important part of each project. Without logs, the controllability of the system is lost. Without logs, there will be no trace of any problems in the system, which is very dangerous for an information system.
However, when we use the pure OOP idea for log processing
Spring Integration: config log4j in Web. XML Pom.xml =============================================================================================================== ===log4j Basic ConceptsLogger: Log output, provides output log function. Appender: The log destination used to define the log destination object. Several common Appender, the first two are more commonly used: Consoleappend
The project uses log4j print content to transfer to flume1, Flume endThe agent configuration for Flume is as follows:
12345678910111213141516
a1.sources=s1a1.sinks=k1a1.channels=c1a1.sources.s1.channels=c1a1.sinks.k1.channel=c1a1.sources.s1.type=avroa1.sources.s1.bind=vm1a1.sources.s1.port=41414 a1.sinks.k1.type=loggera1.channels.c1.type=memorya1.channels.c1.capacity=1000a1.channels.c1.transactionCapacity=100
Start the
Log4j defines the Log Level and log4j Log Level of a class.
After a scheduled task is introduced into the project, when I delete an existing scheduled task
[Org. springframework. scheduling. quartz. localperformancejobstore] ClusterManager: detected 1 failed or restarted instances.[Org. springframework. scheduling. quartz. localperformancejobstore] ClusterManager: Scanning for instance "***"'s failed in
When using Maven to build a hadoop application:
Missing artifact log4j: log4j: jar: 1.2.15: Compile
In Pom. XML, the configuration is
The reason is that log4j has changed the protocol in version 1.2.15 and later, which is in conflict with JMS. There are two solutions: Version 1.2.14 and JMS. jar are manually downloaded and installed in the maven local reposi
Link: http://blog.csdn.net/guoquanyou/article/details/5689652
Do the project is log4j output format parameters annoying, simply put the relevant parts of the API roughly translated, the original see http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html
Parameters
Description
Example
%c
Lists the full name
steps:
Create a new Java project and import the log4j jar package;
Create the Log4j.properties profile and set it in the SRC directory;1 # Set the global output level2Log4j.rootlogger=Error,stdout,file3 4 # Output logs above the error level to the console5log4j.appender.stdout=Org.apache.log4j.ConsoleAppender6log4j.appender.stdout.target=System.out7log4j.appender.stdout.layout=Org.apache.log4j.PatternLayout8Log4j.appender.stdout.layout.conversio
Requirements: Place the log4j.properties configuration problem in the specified folder outside the project. Specific reasons refer to http://blog.csdn.net/lihe2008125/article/details/7764247.
By default, log4j automatically loads the configuration file in Classpath. And log4j.properties that are not packaged take precedence over log4j.properties files that are larger in the jar package. (Here you can recall the configuration in your project)
You can a
The following is written in the official log4j API, which is sufficient to explain the difference between logger and category...
public class Category
Extends java. Lang. Object
Implements appenderattachable
This class has been deprecated andReplaced byLogger Subclass. ItWill be kept around to preserve backward compatibility until mid2003.
LoggerIs a subclass of category, I. e. It extendsCategory. In other words, a loggerIsA c
Do the project is log4j output format parameters annoying, simply put the relevant parts of the API roughly translated, the original see http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.htmlParameter Description Example%c lists the full name of the logger namespace, and if the addition of the {Suppose the current logger namespace is "A.B.C"
Log4j configuration file is used to set the recorder level, storage device, and layout. It can be connected to key = value format settings or XML format settings. Through configuration, you can create a log4j runtime environment.
1. Configuration FileThe basic format of the log4j configuration file is as follows:# Configure the root Logger
Received a demand, through the log4j time print log, requirements described as follows: the need to be able to print the log regularly, the interval can be matched. When it comes to timing, first think of the Dailyrollingfileappender class, various timing, according to Datepattern, this can refer to class SimpleDateFormat class, common some of the regular settings are as follows:
[HTML]View Plain copy print? '.' YYYY-MM: Monthly '. ' YYYY-WW: Weekly '
log4j Configuration Sample
#定义根日志级别和输出端 (two outputs defined) Log4j.rootlogger=error,console,orclight #定义第一个输出端, output to console log4j.appender.console=
Org.apache.log4j.ConsoleAppender Log4j.appender.console.layout=org.apache.log4j.patternlayout log4j.appender.console.layout.conversionpattern=%d [%t]%-5p%c (%l)-%m%n #定时第二个输出端, output to a file with a maximum space of 1000KB, Automatically back up after 1000KB, generate new files Log4j.appender.or
not long for me to come here, so I did not participate in it, but many people have gone through it. Of course, I only need to make modifications. This is the problem of the data connection pool. This is really difficult to grasp, so let's talk about it. "As long as money can solve the problem, it is not a problem. As long as there is an "Explicit problem, it is not a problem", a lot of errors are reported in the background, and you know how to solve them. If everything is good, the program runs
Apache log4j Study Notes:Http://www.cnblogs.com/TopZhujia/archive/2010/05/15/1789993.html
(Xml configuration file)
Below, the configuration file is Properties
Commons-logging + log4j Getting Started Guide [ZT] Original: Zhuang Xiaoli (liigo)Www.liigo.com2005-8-13
Why do I use both commons-logging and log4j? Why not only use one of them?The purpose of commons-Lo
The powerful function of log4j is unquestionable, but in practical application it is unavoidable to have a function to output independent log files, how to separate the required content from the original log, and form a separate log file. In fact, as long as the existing log4j based on a little configuration can easily achieve this function.
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.