開啓JBoss as 7的access_log功能

前言

對於一個網站來說,訪問日誌,即access_log,對網站來說是一項很重要的功能。利用它,我們可以統計出很多有用的信息,從而給網站的運維帶來方便,所以基本上每個網站都會開啓這件功能。

 

配置

在默認的情況下,JBoss7.1是沒有開啓access_log的,如果要開啓這項功能,就需要修改$JBOSS_HOME\standalone\configuration\standalone.xml這個文件,相關的修改內容如下所示:

<subsystem xmlns="urn:jboss:domain:web:1.0"default-virtual-server="default-host">
    <connector name="http"scheme="http" protocol="HTTP/1.1" socket-binding="http"/>
     <virtual-server name="default-host" enable-welcome-root="true">
      <alias name="localhost"/>
      <alias name="example.com"/>
      <access-log/>
    </virtual-server>
</subsystem>

wildy8,9 加入粗體一行即可

<subsystem xmlns="urn:jboss:domain:undertow:2.0">
            <buffer-cache name="default"/>
            <server name="default-server">
                <http-listener name="default" socket-binding="http" redirect-socket="https"/>
                <host name="default-host" alias="localhost">
                    <location name="/" handler="welcome-content"/>
                    <access-log />
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                </host>
            </server>
            <servlet-container name="default">
                <jsp-config/>
                <websockets/>
            </servlet-container>
            <handlers>
                <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server" header-value="WildFly/9"/>
                <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
            </filters>
        </subsystem> 


Jboss as 5,找到jbossweb.sar\server.xml,取消下面註釋

<Valve className="org.apache.catalina.valves.AccessLogValve"
                prefix="localhost_access_log." suffix=".log"
                pattern="common" directory="${jboss.server.log.dir}" 
                resolveHosts="false" />


結束語

當完成上面的配置並重啓服務器後,你就可以訪問一下你的網站,然後你就會在$JBOSS_HOME\standalone\log\default-host目錄下看到一個名爲access_log.2012-02-24的文件,它就是你所需要的訪問日誌啦。

Jboss as 5 ref https://developer.jboss.org/thread/149621?start=0&tstart=0
轉自:http://blog.csdn.net/rickyhome/article/details/7309367
發佈了13 篇原創文章 · 獲贊 3 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章