??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美日韩一级黄,天天射综合网视频,日本在线视频www鲁啊鲁http://www.aygfsteel.com/zhangwei217245/Always Beyond the Timezh-cnTue, 17 Jun 2025 01:59:15 GMTTue, 17 Jun 2025 01:59:15 GMT60【Math's History】什么是|素悖论http://www.aygfsteel.com/zhangwei217245/archive/2014/09/25/418250.htmlX-SpiritX-SpiritWed, 24 Sep 2014 16:57:00 GMThttp://www.aygfsteel.com/zhangwei217245/archive/2014/09/25/418250.htmlhttp://www.aygfsteel.com/zhangwei217245/comments/418250.htmlhttp://www.aygfsteel.com/zhangwei217245/archive/2014/09/25/418250.html#Feedback0http://www.aygfsteel.com/zhangwei217245/comments/commentRss/418250.htmlhttp://www.aygfsteel.com/zhangwei217245/services/trackbacks/418250.html阅读全文

X-Spirit 2014-09-25 00:57 发表评论
]]>
【Effective】IntelliJ IDEA MAC IDE config fileshttp://www.aygfsteel.com/zhangwei217245/archive/2014/03/16/411109.htmlX-SpiritX-SpiritSun, 16 Mar 2014 15:03:00 GMThttp://www.aygfsteel.com/zhangwei217245/archive/2014/03/16/411109.htmlhttp://www.aygfsteel.com/zhangwei217245/comments/411109.htmlhttp://www.aygfsteel.com/zhangwei217245/archive/2014/03/16/411109.html#Feedback0http://www.aygfsteel.com/zhangwei217245/comments/commentRss/411109.htmlhttp://www.aygfsteel.com/zhangwei217245/services/trackbacks/411109.html

IDE Settings

IDE settings are stored in the dedicated directories under the product home directory, depending on the platform. The product home directory name is composed of the product name and version.

For IntelliJ IDEA Community edition the folder name is .IdeaICXX.

For example:

Windows
  • <User home>\.IntelliJIdeaXX\config that contains user-specific settings.
  • <User home>\.IntelliJIdeaXX\system that stores IntelliJ IDEA data caches.

<User home> in WindowsXP is C:\Documents and Settings\<User name>\; in Windows Vista it is C:\Users\<User name>\

Linux
  • ~/.IntelliJIdeaXX/config that contains user-specific settings.
  • ~/.IntelliJIdeaXX/system that stores IntelliJ IDEA data caches.

Mac OS
  • ~/Library/Application Support/IntelliJIdeaXX contains the catalog with plugins.
  • ~/Library/Preferences/IntelliJIdeaXX contains the rest of the configuration settings.
  • ~/Library/Caches/IntelliJIdeaXX contains data caches, logs, local history, etc. These files can be quite significant in size.
  • 9.0+~/Library/Logs/IntelliJIdeaXX contains logs

The config directory has several subfolders that contain xml files with your personal settings. You can easily share your preferred keymaps, color schemes, etc. by copying these files into the corresponding folders on another IntelliJ IDEA installation. Prior to copying, make sure that IntelliJ IDEA is not running, because it can erase the newly transferred files before shutting down.

The following is the list of some of the subfolders under the config folder, and the settings contained therein.

Folder nameUser Settings
codestyles Contains code style schemes.
colors Contains editor colors and fonts customization schemes.
filetypes Contains user-defined file types.
inspection Contains code inspection profiles.
keymaps Contains IntelliJ IDEA keyboard shortcuts customizations.
options Contains various options, for example, feature usage statistics and macros.
templates Contains user-defined live templates.
tools Contains configuration files for the user-defined external tools.
shelf Contains shelved changes.

Locations of the Config, System, and Plugins directories can be modified in IntelliJ IDEA_home\bin\idea.properties file.

You will need to adjust the following parameters:

  • idea.config.path
  • idea.system.path
  • idea.plugins.path


Increasing productivity

To increase productivity of IntelliJ IDEA, you can change settings that reside in the following locations (depending on your operating system):

  • On Windows systems:
    <IntelliJ IDEA installation folder>/bin/idea.exe.vmoptions
        
    or
    <IntelliJ IDEA installation folder>/bin/idea64.exe.vmoptions
        
  • On *NIX systems:
    <IntelliJ IDEA installation folder>/bin/idea.vmoptions
        
    or
    <IntelliJ IDEA installation folder>/bin/idea64.vmoptions
        
  • On Mac OS:

    Since version 12:
    The file /Applications/IntelliJ IDEA.app/bin/idea.vmoptions should be copied to

    ~/Library/Preferences/IntelliJIdeaXX/idea.vmoptions

Example. increasing heap size

For example, to increase IntelliJ IDEA heap size, you should copy the original .vmoptions file from /Applications/IntelliJ IDEA.app/bin/idea.vmoptions to~/Library/Preferences/IntelliJIdeaXX/idea.vmoptions, then modify the -Xmx setting.

For the older versions, the settings are stored in:

                    /Applications/IntelliJ IDEA.app/Contents/Info.plist

Managing case of unicode literals

11.1+

IntelliJ IDEA allows defining whether non-ascii characters should use literals like '\u00AB' or '\00ab'.

This behavior is controlled by the system property idea.native2ascii.lowercase. By default, upper case characters are used.

If it is desirable to use lower case characters, do the following (depending on your platform)

  • 12.0+On Windows and *NIX: add the line
        idea.native2ascii.lowercase=true
        

    to the bin/idea.properties file, located under the product installation.

  •  On Mac OS:

    Copy the file /Applications/IntelliJ IDEA.app/bin/idea.properties to ~/Library/Preferences/IntelliJIdeaXX/, open it for editing, and add the line

        idea.native2ascii.lowercase=true
        

    It is essential to create a copy, since the settings are replaced rather than added.

    For the older versions of IntelliJ IDEA, open for editing the file /Applications/IntelliJ IDEA.app/Contents/Info.plist, and add the following code:

        <key>idea.native2ascii.lowercase</key>
        <string>true</string>
        

    to the section <key>Properties</key> <dict> ... <dict>


To change IDEA running JDK, set <JVMVersion>  to 1.7* in /Applications/IntelliJ IDEA 13.app/Contents/Info.plist


VM arguments settings:


  • -Xms512m  
  • -Xmx512m  
  • -Xmn164m  
  • -XX:MaxPermSize=250m  
  • -XX:ReservedCodeCacheSize=64m  
  • -Xverify:none  
  • -Xnoclassgc  
  • -XX:+UseParNewGC  
  • -XX:+UseConcMarkSweepGC  
  • -XX:CMSInitiatingOccupancyFraction=85  
  • -ea 



  • X-Spirit 2014-03-16 23:03 发表评论
    ]]>
    5 Ways To Burn Out Programminghttp://www.aygfsteel.com/zhangwei217245/archive/2014/02/12/409792.htmlX-SpiritX-SpiritWed, 12 Feb 2014 15:38:00 GMThttp://www.aygfsteel.com/zhangwei217245/archive/2014/02/12/409792.htmlhttp://www.aygfsteel.com/zhangwei217245/comments/409792.htmlhttp://www.aygfsteel.com/zhangwei217245/archive/2014/02/12/409792.html#Feedback0http://www.aygfsteel.com/zhangwei217245/comments/commentRss/409792.htmlhttp://www.aygfsteel.com/zhangwei217245/services/trackbacks/409792.htmlfromQ?http://blog.braegger.pw/5-ways-to-burn-out-programming/


    I've only recently come out of my burnout, despite it happening years ago. It sucks. It sucks bad. But looking back, I can see many of the causes crystal clearly, that weren't so apparent at the time. Here's a list:

    1. Think about your project and only the project

    Let's face it. Business wants you to make the best product you can "for our customers". You put off fun features for the sake of missing a deadline. You plan and analyze and break a project into sets of deliverables that then must be coded by a monkey (you). You demo it, gather feedback, iterate. All without thinking anything for yourself.

    But newsflash: you started programming because you thought it was fun, why not keep programming because it's fun? Take that little extra time to put in a feature you want. Challenge yourself a little bit in doing something you didn't think you could. Show it to everyone you know, and don't just ask for feedback, but brag about what you've done.

    2. Have a negative attitude toward everything.

    You know Docker? It sucks. Who would trust their production environment to a new, unstable, toy. Go? Do I look like I want to write every library myself? Everything I need is already in PyPI. This project I'm working on is so caught up in office politics, it's never going to work. Jenkins? 2008 wants their tech back.

    It's really easy to fall into the "being critical" trap. It's easy to tell other people what the "wrong" choice is. I imagine it's because as software engineers, our job is so find faults in our applications and fix them. And if we don't find them, someone else finds them for us.

    But I don't think we need to be negative about our job, decisions that are being made (even if it's not our decision) and what we're working on. Some of the best projects I've worked on worked out that way because we had a great, positive team. We enjoyed showing up every day to work, told each other when we did awesome things, held back heavy-handed criticism and phrased it in a productive manner.

    3. Use the tools you know, because you're faster that way

    So you're an uber expert in Java + Spring + Hibernate. Nobody can touch your python skillz. Every personal project you do should be in these, because all that matters is the business side of things, right?

    Wrong.

    While it definitely makes good business sense, you should prototype, play around, and become an expert in new tech, even if it's unvetted. While this might seem like obvious advice (it's repeated alllll the time), it becomes a lot harder to do as you grow more experienced.

    4. Switch jobs often

    Otherwise known as "chasing butterflies". Getting bored with what you're working on? Have an itch? Time to dust off that resume!

    This is bad, bad, bad.

    When you have several short employments, it can usually help boost your salary quite a bit, but you are robbing yourself of:

    1. Growing in the company (developer -> manager -> director)
    2. Gaining an expertise in a specific area. Considering it takes 4-6 years for a PhD student to get their PhD, that's a lot of time you need for learnin.
    3. You are having to start from scratch often.
    4. If you are a good developer, you have to "prove" yourself (people listen to you) all over again.

    So how do these contribute to burnout? Your career stagnates, you don't develop your skills as deeply (only breadth), people dont trust you'll stay employed for a while, and you're constantly having to prove yourself.

    5. Work long hours, ignore your life

    "You don't have to work a lot of hours, but some people choose to." You want to impress your boss. Hell, you want to impress yourself. So you go die-hard to meet an impossible deadline. You delivered the project on time, with all the extra features you wanted. You are the hero. High fives all around. And if you're lucky, you'll get that bonus.

    That's great the first time. But how about the second. And the third. It's a bomb, and you dont know how short the fuse is.

    Summary

    In short, it's easy to burnout. Do these 5 things, and you can burnout too.



    X-Spirit 2014-02-12 23:38 发表评论
    ]]>
    【Efficiency】快速配|ubuntu桌面环境之Java环境配置[全Y件源安装]http://www.aygfsteel.com/zhangwei217245/archive/2014/01/11/409716.htmlX-SpiritX-SpiritSat, 11 Jan 2014 03:42:00 GMThttp://www.aygfsteel.com/zhangwei217245/archive/2014/01/11/409716.htmlhttp://www.aygfsteel.com/zhangwei217245/comments/409716.htmlhttp://www.aygfsteel.com/zhangwei217245/archive/2014/01/11/409716.html#Feedback0http://www.aygfsteel.com/zhangwei217245/comments/commentRss/409716.htmlhttp://www.aygfsteel.com/zhangwei217245/services/trackbacks/409716.html
    0. 安装一pd支持工具

    |络工具wget、curl、axel{?br />
    代码:
    sudo apt-get install wget curl axel

    其他常见工具
    代码:
    sudo apt-get install subversion git sysstat linux-base linux-tools-generic build-essential vim emacs unrar p7zip synaptic

    安装常用数据库和NoSQL
    代码:
    sudo apt-get install mysql-client mysql-server mysql-workbench memcached redis-server


    1. 首先dwebupd8的java源:

    代码:
    sudo add-apt-repository ppa:webupd8team/java


    2. 更新源中的Y件数据:

    代码:
    sudo apt-get update


    3. 安装java6或者java7, 当然也可以两者都?br />
    代码:
    sudo apt-get install oracle-java8-installer
    sudo apt
    -get install oracle-java9-installer


    4. 安装maven和ant

    代码:
    sudo apt-get install maven ant

    本方法在UBUNTU 13.04版本中默认安装的是maven 3.0.4版本和ant 1.8版本。如有特D版本嗜好,误行到apache.org下蝲安装?br />
    5. 配置Maven

    功夫|内用户可参照下面的链接q行配置Q?br />
    http://maven.oschina.net/help.html

    其他地区用户可自行到股沟上问癑ֺ?br />
    6. 下蝲安装一U主?JAVA IDE?nbsp;

    Q?Q?下蝲安装 IntelliJ IDEA

    讉KQ?Ҏ需要选择版本。推荐选择Free 30-day trial的Ultimate版本Q至于激zȝ嘛,问度娘,你懂的~

    axel -n 10 "http://download.jetbrains.com/idea/ideaIU-14.1.3.tar.gz"

    tar xzvf ideaIU-14.1.3.tar.gz

    cd idea-IU-141.1010.3/bin

    sh idea.sh

    最后要提醒一句。对于在校学生,拥有.edu邮箱的朋友,可以用你们的.edu邮箱获取一q的jetbrains旗下所有IDE产品的一q免费用权。详?/div>
    https://www.jetbrains.com/student/
    一q过后,只要你的邮箱q能用,可以再次甌?/div>


    Q?Q?下蝲安装eclipse IDE。(alternative stepQ?br />
    讉Khttp://www.eclipse.org/downloads/Q根据需要选择IDE版本。推荐选择Eclipse IDE for Java EE Developers版本。可以根据系l情况选择安装32位或?4?br /> q里以下?4位ؓ?br />
    代码:

    axel -10 "http://ftp.daum.net/eclipse//technology/epp/downloads/release/mars/R/eclipse-jee-mars-R-linux-gtk-x86_64.tar.gz"
    tar -zxvf 
     eclipse-jee-luna-SR2-linux-gtk-x86_64.tar.gz


    然后是自己创徏快捷方式到桌面之cȝ?br />
    Q?Q?下蝲netbeans IDE. Qalternative stepQ?br />
    讉Kwww.netbeans.orgQ然后找C载地址?br /> q里以下?.0.2版本ZQ?br />
    代码:
    axel -10 "http://dlc-cdn.sun.com/netbeans/8.0.2/final/bundles/netbeans-8.0.2-linux.sh"
    sh 
    netbeans-8.0.2-linux.sh


    把netbeans配置为全屏反锯模式Q?br />
    代码:
    cp netbeans.conf netbeans.conf.bak; awk -F'=' '{if($1=="netbeans_default_options"){print index($0,"useSystemAAFontSettings")?$0:substr($0,0,length($0))" -J-Dawt.useSystemAAFontSettings=on\""}else{print $0}}' netbeans.conf.bak > netbeans.conf




    7. 如果惛_快速原型或者玩一玩的话,也可以安装一下nodejs。很有意思?br />
    代码:
    sudo curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -

    sudo apt
    -get install nodejs


    8. GraphDB 最q很火。装个neo4j试试看?br />
    代码:
    wget -- http://debian.neo4j.org/neotechnology.gpg.key | apt-key add -
    sudo echo 
    'deb http://debian.neo4j.org/repo stable/' > /etc/apt/sources.list.d/neo4j.list
    sudo apt-get update
    sudo apt
    -get install neo4j


    X-Spirit 2014-01-11 11:42 发表评论
    ]]>【Efficiency】MAC下用设定可以从mission control中启动的eclipse.app?/title><link>http://www.aygfsteel.com/zhangwei217245/archive/2013/02/25/410286.html</link><dc:creator>X-Spirit</dc:creator><author>X-Spirit</author><pubDate>Mon, 25 Feb 2013 06:53:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhangwei217245/archive/2013/02/25/410286.html</guid><wfw:comment>http://www.aygfsteel.com/zhangwei217245/comments/410286.html</wfw:comment><comments>http://www.aygfsteel.com/zhangwei217245/archive/2013/02/25/410286.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhangwei217245/comments/commentRss/410286.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhangwei217245/services/trackbacks/410286.html</trackback:ping><description><![CDATA[@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); @import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">eclipse官方是有标准的mac版下载的Q随便copyC个目录就可以直接启动?当然必须安装javaq行环境)。但是,假如我们x应用攑ֈmac的标准目录下(也就是finder里的应用E序目录?Q就必须自己手动来做了,Ҏ如下Q?/p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">1.在finder下,copy eclipse目录下的Eclipse.app(在finder里是看不到appq个后缀名的Q必ȝCommand+iQ才能看到这个后~?文g?#8220;应用E序”</p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">2.然后Q点d键,选择“昄包内?#8221;</p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><img src="" alt="" style="border: none; max-width: 100%;" /><img src="http://img.blog.csdn.net/20130914220143781?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2FuZ2ppYW41NzQ4/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" style="border: none; max-width: 100%;" /><br /> </p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">3.修改eclipse.ini文g</p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><img src="http://img.blog.csdn.net/20130914220153250?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2FuZ2ppYW41NzQ4/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" style="border: none; max-width: 100%;" /><br /> </p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><img src="" alt="" style="border: none; max-width: 100%;" /><br /> </p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">修改文g的开头部?/p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">原始内容为:</p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">-startup ../../../plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar<br /> --launcher.library ../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.200.v20130521-0416<br /> </p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">修改后的内容为:</p> <span style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">-startup /Users/johnny/work/eclipse/plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar</span> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">--launcher.library /Users/johnny/work/eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.200.v20130521-0416<br /> </p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">我mac的用户名johnnyQ在我的用户名下有个work目录Q我把eclipse的原始目录放在work下面?/p> <p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">q样可以在“应用E序”下,启动eclipse?/p> @import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);<img src ="http://www.aygfsteel.com/zhangwei217245/aggbug/410286.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhangwei217245/" target="_blank">X-Spirit</a> 2013-02-25 14:53 <a href="http://www.aygfsteel.com/zhangwei217245/archive/2013/02/25/410286.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【Effective】如何迁Ugit仓库http://www.aygfsteel.com/zhangwei217245/archive/2012/11/12/409785.htmlX-SpiritX-SpiritMon, 12 Nov 2012 10:58:00 GMThttp://www.aygfsteel.com/zhangwei217245/archive/2012/11/12/409785.htmlhttp://www.aygfsteel.com/zhangwei217245/comments/409785.htmlhttp://www.aygfsteel.com/zhangwei217245/archive/2012/11/12/409785.html#Feedback0http://www.aygfsteel.com/zhangwei217245/comments/commentRss/409785.htmlhttp://www.aygfsteel.com/zhangwei217245/services/trackbacks/409785.html

    from: 

           http://segmentfault.com/q/1010000000124379

     


    如果你想从别?Git 托管服务那里复制一份源代码到新?Git 托管服务器上的话Q可以通过以下步骤来操作?/p>

    1). 从原地址克隆一份裸版本库,比如原本托管?GitHub?/p>

    git clone --bare git://github.com/username/project.git

    2). 然后到新?Git 服务器上创徏一个新目Q比?GitCafe?/p>

    3). 以镜像推送的方式上传代码?GitCafe 服务器上?/p>

    cd project.git

    git push --mirror git@gitcafe.com/username/newproject.git

    4). 删除本地代码

    cd ..

    rm -rf project.git

    5). 到新服务?GitCafe 上找?Clone 地址Q直?Clone 到本地就可以了?/p>

    git clone git@gitcafe.com/username/newproject.git

    q种方式可以保留原版本库中的所有内宏V?/p>




    X-Spirit 2012-11-12 18:58 发表评论
    ]]>【{】阅L们的学科——计机专业学习谈http://www.aygfsteel.com/zhangwei217245/archive/2012/10/04/389041.htmlX-SpiritX-SpiritThu, 04 Oct 2012 13:54:00 GMThttp://www.aygfsteel.com/zhangwei217245/archive/2012/10/04/389041.htmlhttp://www.aygfsteel.com/zhangwei217245/comments/389041.htmlhttp://www.aygfsteel.com/zhangwei217245/archive/2012/10/04/389041.html#Feedback1http://www.aygfsteel.com/zhangwei217245/comments/commentRss/389041.htmlhttp://www.aygfsteel.com/zhangwei217245/services/trackbacks/389041.html阅读全文

    X-Spirit 2012-10-04 21:54 发表评论
    ]]>
    【Tech Details】【{】有关Java SPI机制http://www.aygfsteel.com/zhangwei217245/archive/2012/03/03/410530.htmlX-SpiritX-SpiritSat, 03 Mar 2012 03:34:00 GMThttp://www.aygfsteel.com/zhangwei217245/archive/2012/03/03/410530.htmlhttp://www.aygfsteel.com/zhangwei217245/comments/410530.htmlhttp://www.aygfsteel.com/zhangwei217245/archive/2012/03/03/410530.html#Feedback0http://www.aygfsteel.com/zhangwei217245/comments/commentRss/410530.htmlhttp://www.aygfsteel.com/zhangwei217245/services/trackbacks/410530.html
    转自Qhttp://blog.csdn.net/fenglibing/article/details/7083071

    一个服?service)通常指的是已知的接口或者抽象类Q服务提供方是对这个接口或者抽象类的实玎ͼ然后按spi标准存放到资源\径META-INF/services目录下,文g的命名ؓ该服务接口的全限定名。如有一个服务接口com.test.ServiceQ其服务实现cMؓcom.test.ChildServiceQ那此时需要在META-INF/services中放|文件com.test.ServiceQ其中的内容׃ؓ该实现类的全限定名com.test.ChildServiceQ有多个服务实现Q每一行写一个服务实玎ͼ#后面的内容ؓ注释Qƈ且该文g只能够是以UTF-8~码?/span>
        q种实现方式Q感觉和我们通常的开发方式差不多Q都是定义一个接口,然后子类实现父类中定义的ҎQؓ什么要搞这么一套标准以及单独搞一个配|文Ӟq种方式主要是针对不同的服务提供厂商Q对不同场景的提供不同的解决Ҏ制定的一套标准,举个单的例子Q如现在的JDK中有支持音乐播放Q假讑֏支持mp3的播放,有些厂商惛_q个基础之上支持mp4的播放,有的x持mp5Q而这些厂商都是第三方厂商Q如果没有提供SPIq种实现标准Q那只有修改JAVA的源代码了,那这个弊端也是显而易见的Q也是不能够随着JDK的升U而升U现在的应用了,而有了SPI标准QSUN公司只需要提供一个播放接口,在实现播攄功能上通过ServiceLoad的方式加载服务,那么W三方只需要实现这个播放接口,再按SPI标准q行打包成jarQ再攑ֈclasspath下面OK了,没有一点代码的侵入性?/span>

        以下是找到的几篇文章Q?/p>

        1?a target="_blank" style="color: #ca0000; text-decoration: none;">http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.htmlQ这个是官方的文档,有对service的详l介l,包括规范以及一个简单的CZQ这个是学习SPI必须看的文档Q?/p>

        注:http://docs.oracle.com/javase/1.4.2/docs/guide/jar/jar.html#Service%20ProviderQ这个是1.4中对Service Provider的介l,加蝲服务是通过sun.misc.Serviceq行加蝲的,q个也有相应的示例,照做OKQ?/p>

        2、Java的SPI机制Q?a target="_blank" style="color: #ca0000; text-decoration: none;">http://www.2cto.com/kf/201012/79868.htmlQ这个是国h写的一示例文章,也挺不错Q里面也有一个简单的CZQ?/p>

        3、Developing a Service Provider using Java API(Service Provider Interface)Q?a style="color: #ca0000; text-decoration: none;">http://blog.csdn.net/fenglibing/article/details/7083526Q这文章是转的alexa发表在blogspot上面的,也是一个开发SPI的示例,有兴的也可以看看;

        4、Add Mp3 capabilities to Java Sound with SPIQ?a target="_blank" style="color: #ca0000; text-decoration: none;">http://www.javaworld.com/javaworld/jw-11-2000/jw-1103-mp3.htmlQ这是一个比较老的例子Q基于jdk1.3的,因ؓ在jdk1.3的时候还没有支持mp3格式Q只支持AU, AIF, MIDI, and WAV{格式,也是一个值得参考的CZ?/p>

        我这边也写了一个简单得不能够再单的CZQ源码可以这里下载:http://download.csdn.net/detail/fenglibing/3939882




    最后很重要一点:


    如果惌覆盖某个ProviderQ可以在对应的META-INF/services的配|文件中加上新service的一行,或者也可以写在另一个有依赖关系的jar包中Q只要和原来的Provider命名不同卛_。加载顺序上可以考虑使用@Priority注解来调整加载的优先U?/p>



    @import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

    X-Spirit 2012-03-03 11:34 发表评论
    ]]>
    【Efficiency?监控 Linux 性能?18 个命令行工具http://www.aygfsteel.com/zhangwei217245/archive/2012/02/19/410062.htmlX-SpiritX-SpiritSun, 19 Feb 2012 14:16:00 GMThttp://www.aygfsteel.com/zhangwei217245/archive/2012/02/19/410062.htmlhttp://www.aygfsteel.com/zhangwei217245/comments/410062.htmlhttp://www.aygfsteel.com/zhangwei217245/archive/2012/02/19/410062.html#Feedback0http://www.aygfsteel.com/zhangwei217245/comments/commentRss/410062.htmlhttp://www.aygfsteel.com/zhangwei217245/services/trackbacks/410062.html

    转自Q?/p>

    http://blog.jobbole.com/59790/

     


    对于pȝ和网l管理员来说每天监控和调试Linuxpȝ的性能问题是一繁重的工作。在IT领域作ؓ一名Linuxpȝ的管理员工作5q后Q我逐渐 认识到监控和保持pȝ启动q运行是多么的不Ҏ。基于此原因Q我们已~写了最怋用的18个命令行工具列表Q这些工具将有助于每个Linux/Unix pȝ理员的工作。这些命令行工具可以在各ULinuxpȝ下用,可以用于监控和查找生性能问题的原因。这个命令行工具列表提供了够的工具Q您可以 挑选适用于您的监控场景的工具?/p>

    1.Top-Linuxq程监控

    Linux下的Top命o是一个性能监控E序Q许多系l管理员常常用它来监控Linux性能Q在许多Linux或者类Unix操作pȝ里都有这个命令。Top命o用于按一定的序昄所有正在运行而且处于zd状态的实时q程Q而且会定期更新显C结果。这条命令显CZCPU的用率、内存用率、交换内存用大、高速缓存用大、缓冲区使用大小Q进EPID、所使用命o以及其他。它q可以显C正在运行进E的内存和CPU占用多的情况。对pȝ理员来_top命o式是一个非常有用的Q它可用于监控系lƈ在需要的时候采取正的处理动作。让我们看看实际中的top命o?/p>

    # top

    13115558_AIkI
    Top命o举例
    有关Top命o更多的例子,请阅?/strong> :Linux?2个用Top命o的例?/a>?/p>

    2. VmStat – 虚拟内存l计

    Linux ?nbsp;VmStat 命o用于昄虚拟内存?strong>内核U程?strong>盘?strong>pȝq程?strong>I/O ?/strong>?strong>中断?strong>CPU zd {的l计信息。缺省情况下Q?vmstat 命o?Linux pȝ下不可用Q你需要安装一个包含了 vmstat E序?nbsp;sysstat 软g包。命令格式的常见用法是:

    1
    2
    3
    4
    # vmstat
    procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
     r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st
     1  0      0 810420  97380  70628    0    0   115     4   89   79  1  6 90  3  0

    更多?vmstat 例子Q请阅读 : 6 Linux 下的 Vmstat 命o实例

    3.Lsof-列出打开的文?/h2>

    在许多Linux或者类Unixpȝ里都有lsof命oQ它常用于以列表的Ş式显C所有打开的文件和q程。打开的文件包?strong>盘文g、网l套接字、管道、设备和q程。用这条命令的主要情Ş之一是在无法挂载磁盘和昄正在使用或者打开某个文g的错误信息的时候。用这条命令,你可以很Ҏ地看到正在用哪个文件。这条命令最常用的格式如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # lsof
    COMMAND     PID      USER   FD      TYPE     DEVICE     SIZE       NODE NAME
    init          1      root  cwd       DIR      104,2     4096          2 /
    init          1      root  rtd       DIR      104,2     4096          2 /
    init          1      root  txt       REG      104,2    38652   17710339 /sbin/init
    init          1      root  mem       REG      104,2   129900     196453 /lib/ld-2.5.so
    init          1      root  mem       REG      104,2  1693812     196454 /lib/libc-2.5.so
    init          1      root  mem       REG      104,2    20668     196479 /lib/libdl-2.5.so
    init          1      root  mem       REG      104,2   245376     196419 /lib/libsepol.so.1
    init          1      root  mem       REG      104,2    93508     196431 /lib/libselinux.so.1
    init          1      root   10u     FIFO       0,17                 953 /dev/initctl

    有关lsof命o的用法和例子的更多信息,请参?/strong>Q?Linux?0个用lsof命o的例?/a>?/p>

    4.Tcpdump-|络包分析器

    Tcpdump是最q泛使用?strong>|络包分析器或者包监控E序之一Q它用于捕捉或者过滤网l上指定接口上接收或者传输的TCP/IP包。它q有一个选项用于把捕捉到的包保存到文仉Q以便以后进行分析。在几乎所有主要的Linux发布里,tcpdump都可以用?/p>

    1
    2
    3
    4
    5
    # tcpdump -i eth0tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
    22:08:59.617628 IP tecmint.com.ssh > 115.113.134.3.static-mumbai.vsnl.net.in.28472: P 2532133365:2532133481(116) ack 3561562349 win 9648
    22:09:07.653466 IP tecmint.com.ssh > 115.113.134.3.static-mumbai.vsnl.net.in.28472: P 116:232(116) ack 1 win 9648
    22:08:59.617916 IP 115.113.134.3.static-mumbai.vsnl.net.in.28472 > tecmint.com.ssh: . ack 116 win 64347

    要想获得更多有关tcpdump用法的信息,请参?/strong>Q?Linux?2个用Tcpdump命o的例子?/a>

    5.Netstat-|络状态统?/h2>

    Netstat是一个用于监?strong>q出|络的包和网l接口统计的命o行工兗它是一个非常有用的工具Q系l管理员可以用来监控|络性能Q定位ƈ解决|络相关问题?/p>

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    # netstat -a | moreActive Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State
    tcp        0      0 *:mysql                     *:*                         LISTEN
    tcp        0      0 *:sunrpc                    *:*                         LISTEN
    tcp        0      0 *:realm-rusd                *:*                         LISTEN
    tcp        0      0 *:ftp                       *:*                         LISTEN
    tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN
    tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN
    tcp        0      0 localhost.localdomain:smtp  localhost.localdomain:42709 TIME_WAIT
    tcp        0      0 localhost.localdomain:smtp  localhost.localdomain:42710 TIME_WAIT
    tcp        0      0 *:http                      *:*                         LISTEN
    tcp        0      0 *:ssh                       *:*                         LISTEN
    tcp        0      0 *:https                     *:*                         LISTEN

    有关Netstat更多的例子,请参?/strong>: Linux?0个用Netstat命o的例子?/a>

    6. Htop – Linuxq程监控

    Htop 是一个非帔RU的交互式的实时linuxq程监控工具? 它和top命o十分怼Q但是它h更丰富的Ҏ,例如用户可以友好地管理进E,快捷键,垂直和水qx式显CE等{? Htop是一个第三方工具Q它不包含在linuxpȝ中,你需要用YUM包管理工具去安装它?关于安装的更多信息,请阅M?

    # htop

    13115601_fiol

    Htop 命oCZ截图

    对于Htop的安装,误 : 在Linux安装Htop(Linuxq程监控)

    7.Iotop-监控Linux盘I/O

    Iotop命o同样也非常类gtop命o?strong>HtopE序Q不q它h监控q显C实?strong>盘I/O和进E?/strong>的统计功能。在查找具体q程和大量用磁盘读写进E的时候,q个工具非常有用?/p>

    # iotop

    13115602_F9DG Iotop命o举例的截?br /> 有关如何安装和用iotop的信息,请阅?/strong>Q?在Linux下安装Iotop?/a>

    8.Iostat-输入/输出l计

    Iostat是一个用于收集显C系l存储设?strong>输入和输?/strong>状态统计的单工兗这个工具常常用来追t存储设备的性能问题Q其中存储设备包?strong>讑֤、本地磁盘,以及诸如使用NFS{的q端盘?/p>

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    # iostat
    Linux 2.6.18-238.9.1.el5 (tecmint.com)         09/13/2012
     
    avg-cpu:  %user   %nice %system %iowait  %steal   %idle
               2.60    3.65    1.04    4.29    0.00   88.42
     
    Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
    cciss/c0d0       17.79       545.80       256.52  855159769  401914750
    cciss/c0d0p1      0.00         0.00         0.00       5459       3518
    cciss/c0d0p2     16.45       533.97       245.18  836631746  384153384
    cciss/c0d0p3      0.63         5.58         3.97    8737650    6215544
    cciss/c0d0p4      0.00         0.00         0.00          8          0
    cciss/c0d0p5      0.63         3.79         5.03    5936778    7882528
    cciss/c0d0p6      0.08         2.46         2.34    3847771    3659776

    有关iostat用法和D例的更多信息Q请讉K: Linux?个用iostat命o的例?/a>?/p>

    9.IPTraf-实时局域网IP监控

    IPTraf是一个在Linux控制台运行的、开放源代码的实时网l(局域网Q监控应用。它采集了大量信息,比如通过|络的IP量监控Q包括TCP标记、ICMP详细信息、TCP/UDP量分离、TCPq接包和字节数。同时还采集有关接口状态的常见信息和详l信息:TCP、UDP、IP、ICMP、非IPQIP校验和错误,接口zd{?/p>

    420140219110741

    IP量监控
    有关IPTraf工具用法以及其他更多信息Q请讉KQ?/strong> IPTraf|络监控工具?/p>

    10. psacct 或?acct – 监视用户zd

    psacct或者acct工具用于监视pȝ里每个用Lzd状况。这两个服务q程q行在后収ͼ它们对系l上q行的每个用L所有活动进行近距离监视Q同时还监视q些zd所使用的资源情c?/p>

    pȝ理员可以用这两个工具跟踪每个用户的活动,比如用户正在做什么,他们提交了那些命令,他们使用了多资源,他们在系l上持箋了多长时间等{?/p>

    有关q些命o的安装和用法举例信息Q请参阅文章Q?a target="_blank" rel="nofollow">使用psacct或者acct监视用户zd?/p>

    11.Monit – Linuxq程和服务监控工?/h3>

    Monit是一个免费的开源YӞ也是一个基于网l的q程监控工具。它能自动监控和理pȝq程Q程序,文gQ文件夹Q权限,d验证码和文gpȝ?/p>

    q个软g能监控像Apache, MySQL, Mail, FTP, ProFTP, Nginx, SSHq样的服务。你可以通过命o行或者这个Y件提供的|络借口来查看系l状态?/p>

    13115605_Gvjb

    Monit Linuxpȝ监控

    更多内容请参阅:用Monit监控Linuxq程

    12.NetHogs-监视每个q程使用的网l带?/h2>

    NetHogs是一个开放源源代码的很小E序Q与Linux下的top命o很相|Q它密切监视着pȝ上每个进E的|络zd。同时还q踪着每个E序或者应用所使用的实时网l带宽?/p>

    13115606_C06o

    NetHogsQLinux下的带宽监视
    更多信息请参阅: 使用NetHogs监视Linux的网l带宽用状c?/a>

    13.iftop-监视|络带宽

    iftop是另一个在控制台运行的开放源代码pȝ监控应用Q它昄了系l上通过|络接口的应用网l带宽用(源主机或者目的主机)的列表,q个列表定期更新。iftop用于监视|络的用情况,?strong>‘top’用于监视CPU的用情ciftop?strong>‘top’工具pd中的一员,它用于监视所选接口,q显CZ个主机间当前|络带宽的用情c?/p>

    720140219110814

    iftop-监视|络带宽?/p>

    更多信息请参阅:iftop-监视|络带宽的用情?/a>?/p>

    14 Monitorix-pȝ和网l监?/strong>

    Monitorix 是一个免费的轻量U应用工P它的设计初衷是运行和监控Linux/Unix服务器系l和资源{。它有一个HTTP |络服务器,q个服务器有规律的收集系l和|络的信息ƈ以图形化的Ş式展C出来。它监控pȝ的^均负载和使用Q内存分配、磁盘健Lc系l服务、网l端 口、邮件统计(SendmailQPostfix,Dovecot{)QMySQLl计Q等{。它是用来监控pȝ的M性能Q帮助发现失误、瓶颈和异常 zd的?/p>

    820140219110833

    15. Arpwatch – 以太|活动监视器

    Arpwatch被设计用来监控Linux上的以太|地址解析 (MAC?strong>IP地址的变?。他在一D|间内持箋监控以太|活动ƈ输出IP和MAC地址配对变动的日志。它q可以向理员发送邮仉知Q对地址配对的增改发告。这对于网l上的ARPd很有用?/p>

    更多信息请参?/strong> : Arpwatch to Monitor Ethernet Activity

    16. Suricata – |络安全监控

    Suricata 是一个开源的高性能|络安全、入侉|和反监工P可以q行Linux、FreeBSD和Windows上。非营利l织OISF (Open Information Security Foundation)开发ƈ拥有其版权?/p>

    更多信息请参?/strong> : Suricata – A Network Intrusion Detection and Prevention System

    17. VnStat PHP – |络量监控

    VnStat PHP 是流行网l工?#8221;vnstat”的基于web的前端呈现?strong>VnStat PHP 网l用情况呈现在漂亮的图形界面中。他可以昄以小时、日、月计的上传和下载流量ƈ输出ȝ报告?/p>

    更多信息请参?/strong> : VnStat PHP – Monitoring Network Bandwidth

    18. Nagios – |络/服务器监?/h3>

    Nagios是领先而强大的开源监控系l,他可以让|络/pȝ理员在问题影响到正常的业务之前发现q解军_们。有了NagiospȝQ管理员可以 在单个窗口内q程Linux、Windows、开兟뀁\由器和打印机。它可以危险警告q指出系l?服务器是否有异常Q这可以间接帮助你在问题发生之前 采取抢救措施?/p>

    更多信息请参?/strong> : Install Nagios Monitoring System to Monitor Remote Linux/Windows Hosts

    我们想知道:你在用什么监控程序来监控Linux服务器的性能呢?如果我们在上面错q了你认为重要的工具Q请在评Z告诉我们Q不要忘了分享它Q?/p>



    X-Spirit 2012-02-19 22:16 发表评论
    ]]>
    【Effective】Logging最佛_?/title><link>http://www.aygfsteel.com/zhangwei217245/archive/2011/02/12/409787.html</link><dc:creator>X-Spirit</dc:creator><author>X-Spirit</author><pubDate>Sat, 12 Feb 2011 11:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhangwei217245/archive/2011/02/12/409787.html</guid><wfw:comment>http://www.aygfsteel.com/zhangwei217245/comments/409787.html</wfw:comment><comments>http://www.aygfsteel.com/zhangwei217245/archive/2011/02/12/409787.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhangwei217245/comments/commentRss/409787.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhangwei217245/services/trackbacks/409787.html</trackback:ping><description><![CDATA[<div><div style="color: #000000; font-family: 微Y雅黑; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><strong>#意识</strong></div> <p><strong style="color: #000000; font-family: 微Y雅黑; font-size: 14px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><span style="color: #0000ff; font-size: medium;">ASAP (As Soon As Possible)原则</span></strong></p> <div style="color: #000000; font-family: 微Y雅黑; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">当线上出现诡异问题,</div> <div style="color: #000000; font-family: 微Y雅黑; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">当你意识到靠现有的日志无法定位问题时Q?/div> <div style="color: #000000; font-family: 微Y雅黑; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">当现象难以在你的开发环境重现时Q?/div> <div style="color: #000000; font-family: 微Y雅黑; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">请不要执著于枯坐肉眼看代码,因ؓQ一Q不一定是你代码逻辑问题Q可能是脏数据造成的,是老业务数据造成的,是分布式环境造成的,是其他子pȝ造成的;二)U上业务处于不稳定中Q条件不允许问题定位无限期?/div> <div style="color: #000000; font-family: 微Y雅黑; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">此时Q?strong>L卛_问题相关的调用链条上Q一ơ性:</strong></div> <div style="color: #000000; font-family: 微Y雅黑; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"> <ul><li><strong>在函数的入口和出口打印日志,同时</strong><strong><span style="font-size: 10.5pt; font-family: 微Y雅黑, sans-serif; color: red;">打印输入、输出参?/span></strong></li><li><strong>catch(){……}里打印stacktraceQ?/strong><strong><span style="font-size: 10.5pt; font-family: 微Y雅黑, sans-serif;">同时</span><span style="font-size: 10.5pt; font-family: 微Y雅黑, sans-serif; color: red;">打印try块中关键变量的|避免你发现某个异常是问题W一原因Q却不知道是什么变量传入导致的Q?/span></strong></li><li><strong>与其他模块交互的接口入口处打印输入参敎ͼ</strong></li></ul> </div> 卻I<strong>解决U上问题归根l底要靠log、a lot of log outputQ?/strong><br /> <div>在logging的力度上切勿犹犹豫UQ我们的工程师习惯于吝啬地找两个函数打印日志、打包部|一把、没看出来、再扑և个函数打印、再部v、等着现象重现再观察?#8230;…Q一来二L间流逝,闲庭信步Q从客服知道的小事故变成了全国皆知的大事故?/div> <div>所以,再强调一遍:<strong>在你的调用链条上Q逐层调用的函数入口和出口都打印详l日志,不怕多只怕少Q然后部|Ԍ{待现象重现Q毕其功于一役!</strong></div> <div> </div> <div> <div><strong><span style="color: #0000ff; font-size: medium;">我们要记录什么?</span></strong></div> <div>1Q完成某Ҏ作所需的时?/div> </div> <div> <p>通过它可以跟tؓ什么系l响应变慢或者太?/p> <ul><li>处理完一个incoming request所耗费的时__到毫U?/li><li>执行数据库查询的旉</li><li>从磁盘或者存储介质获取数据的旉</li><li>{等</li></ul> </div> <div>2Q异常和堆栈跟踪</div> <div> </div> <div>3QSessions</div> <div>知道一个问题是p引v的非帔R要,因此在日志中使用会话标识W就变得必不可少。它可以单到是一?IP 地址或者是一个更复杂?UUIDQ只要能区分不同的请求者就_?/div> <div> </div> <div>4Q版本号</div> <div> </div> <div><strong>#工具</strong></div> <div><strong><span style="color: #0000ff; font-size: medium;">推荐的Java Logging框架</span></strong></div> <div>1Qlog4jQ我们的配置是,log4j.appender.CONSOLE.layout.ConversionPattern= [%-d{yyyy-MM-dd HH\:mm\:ss.SSS}] [%p] [%c] [%m]%nQ?p是日志优先Q?c是类目名Q?m是输Z息,%n是回车换行符?/div> <div>2QlogbackQlog4j创徏人Ceki Gülcü后箋推出了SLF4J+logback。SLF4J(Simple Logging Facade for Java)作ؓcommons-logging的替代,为各Ulogging APIs提供了一个简单的l一接口Q得最l用戯够在部v的时候配|所希望的logging APIs的实现。logback胜在性能Q据U?#8220;某些关键操作Q比如判定是否记录一条日志语句的操作Q其性能得到了显著的提高。这个操作在logback 中需?U秒Q而在 log4j 中则需?0U?U?logback 创徏记录器(loggerQ的速度也更快:13毫秒Q而在 log4j 中需?3毫秒。更重要的是Q它获取已存在的记录器只需94U秒Q?? log4j 需?234U秒Q时间减到?/23。跟java.util.logging(JUL)相比性能提高也是显著?#8221;?/div> <div> </div> <div><strong>#配置</strong></div> <div><strong><span style="color: #0000ff; font-size: medium;">不要随便从网上找一个log4j的配|文ӞL认你理解每一个配|项</span></strong></div> <div>我们既然输出日志Q自然期望在面对“<strong>q个问题是否从过d天开始出玎ͼ</strong>”q样的疑问时Q不至于发现你的rollingPolicy错误讄D只能看到最q几时的日志,或者日志发生时间没有精到毫秒?/div> <div> </div> <div> <div><strong>#理念</strong></div> <div><strong><span style="color: #0000ff; font-size: medium;">可用grep抽取的日志:独立的行Q?/span></strong></div> <div>我们L希望能用grep处理日志文g。这意味着Q?strong>一个日志条目永q不应该跨多行,除非你是堆栈打印</strong>?/div> </div> <div>我们会用grep问日志什么问题呢Q如Q?/div> <div> <ul><li>用手机号13910******下单的顾客最q三天内都来自于哪些IPQ?/li><li>览地址?***?from=kfapi的顾客,但referral却是搜烦引擎域名Q最q三天有多少ơ?</li><li>最q一周内Q订单中心执行的所有事务,耗时最长的一ơ是多长旉Q?/li><li>××××的接口是否真的于18:00发送了一个请求,我们收到的参数是什么?</li></ul> </div> <div>保你的日志能回{这L问题?/div> <div> </div> <div><strong><span style="color: #0000ff; font-size: medium;">不同x领域写不同的日志文g</span></strong></div> <div>当访问和调用极其频繁Q有时候你会发现把你的工程里什么信息都打印C个日志文仉Q会让你看得头昏脑胀?/div> <div>最单的C是Apache的访问日志和错误日志是分开的?/div> <div>同样Q你也可以把更加安静的事Ӟ偶尔出现Q与更加喧闹的事件分开存储?/div> <div>如,对外的开攑^台可以打CU日志文Ӟconnection logQ徏立链接和关闭链接Q附带接入参敎ͼQmessage logQ内部调用链Q,stacktrace logQ异常的堆栈打印Q?/div> <div> </div> <div><strong>#具体实现</strong></div> <div> <div><strong><span style="color: #0000ff; font-size: medium;">臛__到毫U?/span></strong></div> <div>日志必须包含旉戻I_到至毫U?/div> </div> <div>如果只是记录到秒U,我们曾明知代码因~Zq发控制而生BUGQ却只能郁闷地看着_到秒U的日志?/div> <div>对Java来说Q最好配|ؓQ?span style="font-family: tahoma;">yyyy-MM-dd/HH:mm:ss<span style="background-color: yellow; color: #ff0000;">.SSS</span>?/span></div> <div> </div> <div> <div><strong><span style="color: #0000ff; font-size: medium;">请尽可能打印明确的会话标?/span></strong></div> <div>日志条目里打C个会话标识(A certain session identifierQ,当有许多q发h打过来时Q你pZ此字D过?client 了。比如,我们日志会补充打C个浏览器 cookies 里种下的 UUID ?/div> </div> <div> </div> <div><strong><span style="color: #0000ff; font-size: medium;">log4j的isDebugEnabled判断</span></strong></div> <div>如果打印信息是常量字W串或简单字W串拼接Q那么不需要if ( log.isDebugEnabled() )?/div> <div>如果你拼装的动作比较耗资源,Lif ( log.isDebugEnabled() )?/div> <div> </div> <div> <div><strong><span style="color: #0000ff; font-size: medium;">如有可能Q请性能数据标准化输?/span></strong></div> <div>q样更方便grep或hadoop做性能数据抽取和挖掘,从而能很轻村֜转换为图形监控?/div> </div> <div>比如Q订单中心的性能数据格式为:<strong>树枝标志 当前节点起始旉 [当前节点持箋旉, 当前节点自n消耗时? 在父节点中所占的旉比例]</strong></div> <div> </div> <div> <div><strong><span style="color: #0000ff; font-size: medium;">哪些位置需要部|性能点 </span></strong></div> <div>Q?Q访问数据库的dao层;</div> <div>Q?Q访问外部资源的ext层;</div> <div>Q?Q访问mq的方法;</div> <div>Q?Q等{,一切不在你自己负责的工E掌握的部分Q外部)Q或一切你认ؓ自己工程的性能危险点,都需要加入性能监控日志?/div> </div> <div> </div> <div> </div> <div><strong>#Sample</strong></div> <div> <div><span style="color: #0000ff; font-size: medium;"><strong>一个好的启动日?/strong></span></div> </div> <div><a target="_blank"><img style="width: 709px;" src="http://images.cnblogs.com/cnblogs_com/zhengyun_ustc/255879/o_clipboard%20-013%20%E5%89%AF%E6%9C%AC.png" alt="http://images.cnblogs.com/cnblogs_com/zhengyun_ustc/255879/o_clipboard%20-013%20%E5%89%AF%E6%9C%AC.png" /></a></div> <div>打印了应用的版本P客户端的会话标识Q关键步骤的执行旉?/div> <div> </div> <div><strong style="color: #0000ff; font-size: medium;">一个好的堆栈跟t日?/strong></div> <div><a target="_blank"><img style="width: 709px;" src="http://images.cnblogs.com/cnblogs_com/zhengyun_ustc/255879/o_clipboard%20-%20014%E5%89%AF%E6%9C%AC.png" alt="http://images.cnblogs.com/cnblogs_com/zhengyun_ustc/255879/o_clipboard%20-%20014%E5%89%AF%E6%9C%AC.png" /></a></div></div><br /><br /><div>本文首发?a target="_blank">旁观?郑昀</a>?a target="_blank">55最佛_늳?/a>Q链接:<a target="_blank">http://www.cnblogs.com/zhengyun_ustc/archive/2012/12/15/logging_bp.html</a></div><img src ="http://www.aygfsteel.com/zhangwei217245/aggbug/409787.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhangwei217245/" target="_blank">X-Spirit</a> 2011-02-12 19:55 <a href="http://www.aygfsteel.com/zhangwei217245/archive/2011/02/12/409787.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ϰ</a>| <a href="http://" target="_blank">κ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͭϿ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɳ</a>| <a href="http://" target="_blank">з</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ն</a>| <a href="http://" target="_blank">º</a>| <a href="http://" target="_blank">н</a>| <a href="http://" target="_blank">Ƕ</a>| <a href="http://" target="_blank">ԫ</a>| <a href="http://" target="_blank">ֹ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">־</a>| <a href="http://" target="_blank">ξ</a>| <a href="http://" target="_blank">ݳ</a>| <a href="http://" target="_blank">е</a>| <a href="http://" target="_blank">üɽ</a>| <a href="http://" target="_blank">߷</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ຣʡ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ĵ</a>| <a href="http://" target="_blank">Ӣ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>