Weblogic的Access log 自訂日誌

來源:互聯網
上載者:User

weblogic8,在access.log首行加入
如 自訂類c_username
#.... x-c_username

weblogic9,10,使用擴充日誌格式設定 HTTP 訪問日誌
登入console-Servers-AdminServer(admin)-Logging-選擇http-Advanced-
其中Format 選擇Extended
Extended Logging Format Fields : x-c_username date time cs-method cs-uri sc-status bytes cs(Referer) cs(User-Agent) cs(cookie)

代碼實現:
import weblogic.servlet.logging.*; public class c_username implements CustomELFLogger { public c_username() { } public void logField(HttpAccountingInfo httpaccountinginfo, FormatStringBuffer formatstringbuffer) { formatstringbuffer.appendValueOrDash(httpaccountinginfo.getRemoteUser()); } }

參考:
weblogic.servlet.logging
Interface CustomELFLogger


This is an interface which allows customers to add custom information to the ExtendedLogFormat. They will be responsible for implementing logField(HttpAccountingInfo metrics) method. ELF allows users to specify fields to be logged with each http request. One of these #Fields is an application specific field in the form of x-SOMEFIELDNAME WLS expects a fully qualified classname as the argument for this field and attempts to instantiate an instance of this class. Customers are responsible for following formatting guidlines of the specification. For example if they use one class to return two fields then they need to delimit them via a tab See: http://www.w3.org/TR/WD-logfile-960221.html for the specification Also they should use caution as this API provides them the opportunity to do anthying they want basically and they should not do something that will inordinantly SLOW the system down. Like looking something up in the DMBS, or doing signigicant IO or Networking

關鍵類:
weblogic.servlet.logging.LogManagerHttp
weblogic.servlet.logging.ELFLogger
weblogic.servlet.logging.CLFLoggerLogFormat

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.