December 10, 2016 Week work summary

Source: Internet
Author: User
Tags log4j
first, according to the mobile phone number of the query attribution to the interface

Url:https://sp0.baidu.com/8aqdcjqpaav3otqbppnn2djv/api.php?cb=test
&resource_name=guishudi
&query=18052178970
&_=1480906732952

The corresponding results are:

/**/test ({"Status": "0", "T": "", "Set_cache_time": "", "data": [{"Stdstg": 6004, "Stdstl": 8, "_update_time": "1480829021 "," loc ":" https:\/\/ss1.baidu.com\/8aqdcnsm2q5ilbglnyg\/q?r=2002696&k=1805217 "," Key ":" 1805217 "," url ":" http : \/\/haoma.baidu.com "," title ":" XXX "," Showurl ":" http:\/\/haoma.baidu.com "," Prov ":" Jiangsu "," City ":" Xuzhou "," type ":" China Telecom " , "SiteId": 2002696, "_version": 20177, "_select_time": 1480829008, "QueryType": "Mobile Number", "Phoneinfo": "Mobile phone number" 18052178970 " "," Phoneno ":" 18052178970 "," Origphoneno ":" 18052178970 "," Titlecont ":" Mobile number attribution to the query "," Showlamp ":" 1 "," Clickneed ":" 0 "," Extendedlocation ":" "," Originquery ":" 18052178970 "," tplt ":" Mobilephone "," ResourceID ":" 6004 "," Fetchkey ":" 6004_ 1805217 "," appinfo ":" "," role_id ": 1," Disp_type ": 0}]};
Parameter description:

1) CB--Return the result name

2 Query--phone number to be queried

3 Data--return the information related to mobile phone number two, MySQL exception

Things are not submitted, resulting in lock waiting, the exception information is: Lock wait timeout exceeded; Try restarting transaction

Solution:

Perform

After finding a read-only transaction that has not been committed, after finding the corresponding thread, execute the kill thread_id and confirm that the read-only thing that has not been committed is OK. Third, the log4j log output to different files by level

The Warn and error log exist in different files, easy to manage and view, according to the general configuration, the Warn log also contains error information, the configuration of the key configuration instructions is this sentence:
Log4j.appender.warn.Threshold = Warn
And its function is to output warn level above the content to Warn.log, so Warn.log file contains the error level files.

The workaround is to define your own Appender class, inherit the Dailyrollingfileappender, and overwrite the set description for threshold (overriding the comparison method for the level).

Source

public boolean isassevereasthreshold (Priority Priority)  {return    
     threshold = = NULL | | Priority.isgreaterorequal (threshold);    
Overriding the Isassevereasthreshold (Priority Priority) method

public class Myappender extends Dailyrollingfileappender {  
      
    @Override public  
    boolean isassevereasthreshold ( Priority Priority) {    
          ///only to determine if equality is not judged by priority return     
        This.getthreshold (). Equals (Priority);    
    }    
  
Only when the threshold is consistent with the priority, the output is realized, and the true log4j output log file is achieved.

The configuration file is as follows:

### set log levels ### Log4j.rootlogger=info,error,info Log4j.appender.stdout=org.apache.log4j.consoleappender Log4j.appender.stdout.layout=org.apache.log4j.patternlayout log4j.appender.stdout.layout.conversionpattern=%d{     
YYYY-MM-DD-HH-MM} [%t] [%c] [%p]-%m%n log4j.logger.info=info Log4j.appender.info=com.zznode.log.myappender Log4j.appender.info.layout=org.apache.log4j.patternlayout log4j.appender.info.layout.conversionpattern=%d{yyyy- MM-DD-HH-MM} [%t] [%c] [%p]-%m%n log4j.appender.info.datepattern= '. ' Yyyy-mm-dd log4j.appender.info.Threshold = info Log4j.appender.info.append=false log4j.appender.info.file=d:/lo G4j/info.log log4j.logger.error=error Log4j.appender.error=com.zznode.log.myappender Log4j.appender.error. Layout=org.apache.log4j.patternlayout log4j.appender.error.layout.conversionpattern=%d{yyyy-mm-dd-hh-mm} [%t] [%c ] [%p]-%m%n log4j.appender.error.datepattern= '. ' YYYY-MM-DD Log4j.appender.erRor.  Threshold = ERROR Log4j.appender.error.append=false log4j.appender.error.file=d:/log4j/error.log

If it is an XML configuration, you can set it by using the filter:

<filter class= "Org.apache.log4j.varia.LevelRangeFilter" >  
<param name= "levelmin" value= "ERROR"/>  
<param name= "Levelmax" value= "ERROR"/>  

Reference Blog: http://blog.csdn.net/wangchsh2008/article/details/8812857

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.