Hadoop's automated distributed cache Distributedcache (the new version of the API) is often used in the write MapReduce program, but executes in eclipse under Windows, with an error similar to the following:2016-03-03 10:53:21,424 WARN [main] util. Nativecodeloader (nativecodeloader.java:2016-03-03 10:53:22,152 INFO [main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated (1019))- Session.id is deprecated. Instead, use Dfs.metrics.ses
flexibly control the opening or closing of any granularity of log information without modifying the code, and then use the custom format to output the log information to one or more places that you need. And, log4j also has a smooth learning curve, in three minutes to learn its simple use. As you go deeper, you will find that the log4j function is powerful enough to meet all the requirements of the log.Quick StartLook at a piece of code first and see how easy log4j is, and the code is as follow
Recently made a Sina Weibo crawler, using the httpclient-4.3.3, the program runs very well, that is, there will always be a cookie rejected warning, log as follows:
2014-06-05 10:27:17.417 [main] WARN O.a.h.c.p.responseprocesscookies-cookie rejected [u_trs1=] 000000ea.ef542aa2.538fd58b.ec8a8e2c ", version:0, domain:.sina.com.cn, path:/, Expiry:sun June 10:27:23 CST 2024] Illegal domain attribute "sina.com.cn". Domain of Origin: "passport.weibo.com"
static method Logger.getlogger, which takes the name of the logger that you want to get as an argument. Some methods for Logger classes are described as follows: public class Logger {//Creation retrieval Methods:public static Logger Getrootlogger (); public static Logger GetLogger (String name); Printing methods:public void Debug (Object message); public void info (Object message); public void warn (Object message); public void error (Object message
/server/tools/http://nginx.org/download/nginx-1.10.2.tar.gz7#解压文件8cd/server/tools/9Tar zxf nginx-1.10.2. tar.gzTen #编译安装Nginx OneCD nginx-1.10.2 A./configure--prefix=/application/nginx-1.10.2--user=www--group=www--with-http_ssl_module--with-Http_stub_status_module -Make Make Install - creating a soft connection theLn-s/application/nginx-1.10.2//application/nginx2. Scripting[[email protected] ~]# cd/server/scripts/[rootfpm scripts]# vim nginx_rpm.sh # This is the script to execute when the RPM p
Do not get webservicecontext property from stateless bean context, it shoshould already have been injected
This is mainly because of the stateless bean implementation class.
After careful viewing, I found that I added @ webmethod before every method of the implementation class (specifying the method exposed to the outside world), so I can remove it.
13:41:39, 168 warn [statelessbeancontext] EJBTHREE-1337: do not get webservicecontext property
performed, which improves the situation. However, the out of memory situation still occurs after 2-3 days of running, later, I analyzed the log file messages and found the bold part. The analysis was caused by insufficient low memory. Later I tried to use sync; Echo 3>/proc/sys/Vm/drop_caches to release the memory, check whether/proc/buddyinfo memory is released. Jun 10 13:33:11 XX user. Warn kernel: DMA free: 3548kb min: 68kb low: 84kb high: 100kb a
LOG4J supports two configuration file formats, one is the Java property file (the key-value) and the other is the XML format file.
Here is a description of how to configure the Java properties file.First look at the configuration file: Log4j.properties
Log4j.rootcategory=debug,stdout,r
Log4j.appender.stdout=org.apache.log4j.consoleappenderLog4j.appender.stdout.layout=org.apache.log4j.patternlayoutlog4j.appender.stdout.layout.conversionpattern=%5p [%t] (%f:%l)-%m%n
Log4j.appender.r=org.apache.log
.
Tracemode
Set the trail mode: sortbycategory or sortbytime.
Method
Description
Warn
The trace information is displayed in red.
Write
Write tracking information.
To program to disable tracing, you can use the following statement in the load event of webform1:
Trace. isenabled = false
In our example, the trace information is not explicitly
, and an optional addtivity property.
name:Used to specify a package or a specific class that is subject to this loger constraint.
Level:Used to set the print level, case-insensitive: TRACE , DEBUG INFO , WARN , ERROR all , 和 OFF ,还有一个特俗值 inherited 或者同义词 NULL ', which represents the level of enforcement of the ancestor.If this property is not set, the current Loger will inherit the level of the ancestor.
addtivity:Whether to pass
trace attribute in the Page object is an instance of a TraceContext class. The TraceContext class provides two methods: Write and warn, which allow statements to be written to trace records. Each method is overloaded and allows you to specify trace categories, text messages, and optional error messages. The only difference between the two methods is that the Warn method displays its text in red.
Note When
In Windows, APACHE is intermittently suspended. Symptoms: it will be stopped once every two to three days. After APACHE is restarted, it will be normal again. Error log: the network name specified by [ThuNov0609: 59: 402014] [warn] (OS64) is no longer available. : Winnt_accept: AsynchronousAcceptExfailed. the network name specified by [ThuNov0612: 03: 142014] [warn] (OS64) is no longer available. : Winnt_ac
the variable, you can use the variable "$.
For exampleDefine the context name, and thenSet the logger context.
2.3 obtain the timestamp string:
Two attributes:
Key: identifies thisName;
Datepattern: Set to convert the time of the current time (when configuration file to the serial format, in the format of java.txt. simpledateformat.
For example, use the time when the configuration file is parsed as the context Name:
2.4 set Loger:
Set the log printing level of a package or a spe
failures
This example can solve the problem of insufficient error information when Tomcat starts an exception. Use commons-logging and log4j to output detailed log information.
Take tomcat5.5.27 in the window environment as an example:
1. Tomcat decompression directory:
E:/tomcat5.5
2. Set environment variables:
Catalina_home = E:/tomcat5.5
3. Download log4j and commons-logging
Log4j:
Http://logging.apache.org/log4j/1.2/download.html
Commons-logging:
Http://apache.freelamp
large number of warnings may be generated.
In the long run, these warnings must be eliminated, but in the short term?
Even with a long-term plan, you cannot write code with no bugs at all, and you cannot ensure that the application will never print a warning message in the future.
Can you?
You can capture them before warning is printed to the screen.
Signal
Perl has a built-in hash table named % SIG, where the key is the name of the operating system signal. The corresponding value is a function
Document directory
I. Three Components of log4j
Ii. Configuration File
In fact, the use of logs is very simple. 1. Import the log4j package, 2. Define the configuration file, and 3. Use it. General steps: Define the log object → read the configuration file → output to the log. That all.I. Three Components of log4j
Log4j consists of three important components: log priority, appender, and layout.
1. Log priorityFrom low to high, debug, info, warn,
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.