Log4j Introduction Basically all large-scale applications, including our commonly used frameworks, such as Hibernate, spring, and struts, provide a certain amount of log information within them. Why is this log information hard-coded in the system? It is a way to debug the system and observe the system running status. Most programmers may remember that when they first wrote code, they always failed to write a method and liked to use system. out. print
Configuration information of Log4j. xml and Log4j. xml
Source code
1
Log4j. xml configuration
Value = "[% d {dd HH: mm: ss, SSS/} %-5 p] [% t] % c {2/}-% m % n"/>Value = "[% d {MMdd HH: mm: ss SSS/} %-5 p] [% t] % c {3/}-% m % n"/>
(1). There are generally five appender output methods:Org. apache. log4j. RollingFi
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 generation process more carefully.
When Tomcat is started, the following warning is displayed:
Log4j: warn no appenders cocould be found for logger (Org. Apache. commons. digester. digester. Sax ).Log4j: Warn please initialize the log4j system properly.
Solution:
The log4j. properties file must be placed under the web-INF/class directory and placed u
Add log4j to Web. xml and log4j to Web. xml
The configuration file is as follows. Web. xml
The log4jproperties file exists and is also configured in webxml. Why does it still report the above error?
Modify the log4j path to your own path.The log4jxml configuration file supports configuring the time zone. How can I configure the time zone?
1. add
How can we let log4j play its role? The answer is simple, just meet the "log4j jar package" in classpath. As has been said before, Commons-logging will automatically discover and apply log4j. So as long as it exists, it works. (Does it not exist?) Naturally does not work, commons-logging will choose other log implementation classes separately. )
Note: The config
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 of the logger namespace, and if you add the {
Kettle-engine.jar and log4j. jar package conflict problem solution, log4j. jar
Java to call kettle, reference the kettle-engine.jar in lib, log4j. jar package, test found that with the kettle-engine.jar package, log can not be written to the log file, but can print to the console; to the Internet to find many friends encountered similar problems, finally, I foun
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
With log4j, you can easily process logs in your project-control the destination of the Log information output (console, file, GUI component, or NT Event recorder), control the output format of each log (htmllayout layout format, patternlayout layout format, Simplelayout layout format or ttcclayout), controls the level of output log information (debug level, info level, warn level, error level, or fatal level), and so on. Here's a simple example of how
Do the project is log4j output formatting parameters get bored, simply the relevant part of the API is 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 of a logger namespace. If {
Example of parameters in the
Log4j is used in spring, but because the project needs to use the Task Scheduler, so add quartz, but quartz need sfl4j-log4j and SFL4J-API
However, if you use sfl4j-log4j and log4j, there will be conflicts ... Error occurs at startup
Then you need to convert the version of quartz ...
Project original Lib Quartz is 1
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
I started to read "programming language implementation mode" and learned the basics of Parser. English is on Wiki, and Chinese is translated by yourself.
Wiki LALR parserHttp://en.wikipedia.org/wiki/LALR_parser
In 1965, Donald Knuth successfully Ted the LR parser (Left to Right, Rightmost derivation ). the LR parser can recognize any deterministic context-free la
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
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.