隨筆-61  評(píng)論-13  文章-19  trackbacks-0
            2007年12月25日
               摘要:   閱讀全文
          posted @ 2010-02-04 15:30 xnabx 閱讀(1615) | 評(píng)論 (1)編輯 收藏
               摘要:   閱讀全文
          posted @ 2010-01-25 11:10 xnabx 閱讀(1033) | 評(píng)論 (1)編輯 收藏
               摘要:   閱讀全文
          posted @ 2010-01-21 09:52 xnabx 閱讀(1726) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2010-01-15 10:10 xnabx 閱讀(1409) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2010-01-15 09:57 xnabx 閱讀(338) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2009-12-04 11:45 xnabx 閱讀(607) | 評(píng)論 (3)編輯 收藏
               摘要:   閱讀全文
          posted @ 2009-12-03 15:26 xnabx 閱讀(314) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2009-12-01 16:02 xnabx 閱讀(189) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2009-12-01 11:05 xnabx 閱讀(324) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2009-11-10 09:05 xnabx 閱讀(762) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2009-03-18 14:06 xnabx 閱讀(151) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2008-10-29 16:34 xnabx 閱讀(113) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2008-07-30 15:18 xnabx 閱讀(240) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2008-07-23 11:20 xnabx 閱讀(388) | 評(píng)論 (0)編輯 收藏
          出處:http://www.aygfsteel.com/xmatthew/archive/2008/04/14/192450.html
          (轉(zhuǎn))設(shè)計(jì)一個(gè)Tomcat訪問(wèn)日志分析工具
          常使用web服務(wù)器的朋友大都了解,一般的web server有兩部分日志:
              一是運(yùn)行中的日志,它主要記錄運(yùn)行的一些信息,尤其是一些異常錯(cuò)誤日志信息
              二是訪問(wèn)日志信息,它記錄的訪問(wèn)的時(shí)間,IP,訪問(wèn)的資料等相關(guān)信息。
             
          現(xiàn)在我來(lái)和大家介紹一下利用tomcat產(chǎn)生的訪問(wèn)日志數(shù)據(jù),我們能做哪些有效的分析數(shù)據(jù)?

          首先是配置tomcat訪問(wèn)日志數(shù)據(jù),默認(rèn)情況下訪問(wèn)日志沒(méi)有打開(kāi),配置的方式如下:
              編輯 ${catalina}/conf/server.xml文件.注:${catalina}是tomcat的安裝目錄
              把以下的注釋(<!-- -->)去掉即可。
                      <!--
                  <Valve className="org.apache.catalina.valves.AccessLogValve"
                           directory="logs"  prefix="localhost_access_log." suffix=".txt"
                           pattern="common" resolveHosts="false"/>
                  -->
              其中 directory是產(chǎn)生的目錄 tomcat安裝${catalina}作為當(dāng)前目錄
              pattern表示日志生產(chǎn)的格式,common是tomcat提供的一個(gè)標(biāo)準(zhǔn)設(shè)置格式。其具體的表達(dá)式為 %h %l %u %t "%r" %s %b
              但本人建議采用以下具體的配置,因?yàn)闃?biāo)準(zhǔn)配置有一些重要的日志數(shù)據(jù)無(wú)法生。
                  %h %l %u %t "%r" %s %b %T 
          具體的日志產(chǎn)生樣式說(shuō)明如下(從官方文檔中摘錄):
              * %a - Remote IP address
              * %A - Local IP address
              * %b - Bytes sent, excluding HTTP headers, or '-' if zero
              * %B - Bytes sent, excluding HTTP headers
              * %h - Remote host name (or IP address if resolveHosts is false)
              * %H - Request protocol
              * %l - Remote logical username from identd (always returns '-')
              * %m - Request method (GET, POST, etc.)
              * %p - Local port on which this request was received
              * %q - Query string (prepended with a '?' if it exists)
              * %r - First line of the request (method and request URI)
              * %s - HTTP status code of the response
              * %S - User session ID
              * %t - Date and time, in Common Log Format
              * %u - Remote user that was authenticated (if any), else '-'
              * %U - Requested URL path
              * %v - Local server name
              * %D - Time taken to process the request, in millis
              * %T - Time taken to process the request, in seconds

          There is also support to write information from the cookie, incoming header, the Session or something else in the ServletRequest. It is modeled after the apache syntax:

              * %{xxx}i for incoming headers
              * %{xxx}c for a specific cookie
              * %{xxx}r xxx is an attribute in the ServletRequest
              * %{xxx}s xxx is an attribute in the HttpSession


          現(xiàn)在我們回頭再來(lái)看一下下面這個(gè)配置 %h %l %u %t "%r" %s %b %T 生產(chǎn)的訪問(wèn)日志數(shù)據(jù),我們可以做哪些事?
          先看一下,我們能得到的數(shù)據(jù)有:
              * %h 訪問(wèn)的用戶IP地址
              * %l 訪問(wèn)邏輯用戶名,通常返回'-'
              * %u 訪問(wèn)驗(yàn)證用戶名,通常返回'-'
              * %t 訪問(wèn)日時(shí)
              * %r 訪問(wèn)的方式(post或者是get),訪問(wèn)的資源和使用的http協(xié)議版本
              * %s 訪問(wèn)返回的http狀態(tài)
              * %b 訪問(wèn)資源返回的流量
              * %T 訪問(wèn)所使用的時(shí)間
             
          有了這些數(shù)據(jù),我們可以根據(jù)時(shí)間段做以下的分析處理(圖片使用jfreechart工具動(dòng)態(tài)生成):
            * 獨(dú)立IP數(shù)統(tǒng)計(jì)
            * 訪問(wèn)請(qǐng)求數(shù)統(tǒng)計(jì)
            * 訪問(wèn)資料文件數(shù)統(tǒng)計(jì)
            * 訪問(wèn)流量統(tǒng)計(jì)
            * 訪問(wèn)處理響應(yīng)時(shí)間統(tǒng)計(jì)
            * 統(tǒng)計(jì)所有404錯(cuò)誤頁(yè)面
            * 統(tǒng)計(jì)所有500錯(cuò)誤的頁(yè)面
            * 統(tǒng)計(jì)訪問(wèn)最頻繁頁(yè)面
            * 統(tǒng)計(jì)訪問(wèn)處理時(shí)間最久頁(yè)面
            * 統(tǒng)計(jì)并發(fā)訪問(wèn)頻率最高的頁(yè)面



























          分析工具包括兩大部分,一個(gè)是后臺(tái)解釋程序,每天執(zhí)行一次對(duì)后臺(tái)日志數(shù)據(jù)進(jìn)行解析后保存到數(shù)據(jù)庫(kù)中。
          第二個(gè)是顯示程序,從數(shù)據(jù)庫(kù)中查詢數(shù)據(jù)并生成相應(yīng)的圖表信息。
          posted @ 2008-04-15 12:06 xnabx 閱讀(563) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2008-04-09 08:50 xnabx 閱讀(36) | 評(píng)論 (0)編輯 收藏
               摘要:   閱讀全文
          posted @ 2008-03-19 13:00 xnabx 閱讀(190) | 評(píng)論 (0)編輯 收藏

          如果你覺(jué)得你的Eclipse在啟動(dòng)的時(shí)候很慢(比如說(shuō)超過(guò)20秒鐘),也許你要調(diào)整一下你的Eclipse啟動(dòng)參數(shù)了,以下是一些``小貼士'':

          1. 檢查啟動(dòng)Eclipse的JVM設(shè)置。 在Help\About Eclipse SDK\Configuration Detail里面,你可以看到啟動(dòng)Eclipse的JVM。 這個(gè)JVM和你在Eclipse中設(shè)置的Installed JDK是兩回事情。 如果啟動(dòng)Eclipse的JVM還是JDK 1.4的話,那最好改為JDK 5,因?yàn)镴DK 5的性能比1.4更好。

          C:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.5.0_08\ bin\javaw.exe"

          2. 檢查Eclipse所使用的heap的大小。 在C:\eclipse目錄下有一個(gè)配置文件eclipse.ini,其中配置了Eclipse啟動(dòng)的默認(rèn)heap大小

          -vmargs
          -Xms40M
          -Xmx256M

          所以你可以把默認(rèn)值改為:

          -vmargs
          -Xms256M
          -Xmx512M

          當(dāng)然,也可以這樣做,把堆的大小改為256 - 512。

          C:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.5.0_08\ bin\javaw.exe" -vmargs -Xms256M -Xmx512M

          3. 其他的啟動(dòng)參數(shù)。 如果你有一個(gè)雙核的CPU,也許可以嘗試這個(gè)參數(shù):

          -XX:+UseParallelGC

          讓GC可以更快的執(zhí)行。(只是JDK 5里對(duì)GC新增加的參數(shù))

          posted @ 2007-12-25 10:55 xnabx 閱讀(489) | 評(píng)論 (0)編輯 收藏
          主站蜘蛛池模板: 尉氏县| 东至县| 社会| 和顺县| 南宁市| 都安| 芷江| 清水县| 洛扎县| 曲水县| 远安县| 固始县| 高安市| 微山县| 万荣县| 武清区| 乐至县| 余庆县| 高安市| 红桥区| 太仓市| 定兴县| 达孜县| 青冈县| 临湘市| 红桥区| 南皮县| 沂水县| 沂南县| 建始县| 德州市| 阳信县| 固镇县| 浮梁县| 龙岩市| 吉木萨尔县| 建德市| 呼和浩特市| 天水市| 万盛区| 弋阳县|