Weblogic8, join in the first line of Access.log
such as custom class C_username
# ... x-c_username
weblogic9,10, set up HTTP access logs using extended log format
Login console-servers-adminserver (Admin)-logging-Select http-advanced-
where format Select Extended
Extended Logging Format fields:x-c_username Date time cs-method cs-uri sc-status bytes cs (Referer) CS (user-agent) CS (COO Kie)
Code implementation:
Import weblogic.servlet.logging.*; public class C_username implements Customelflogger {public c_username () {} public void Logfield (Httpaccountinginfo httpa Ccountinginfo, Formatstringbuffer formatstringbuffer) {Formatstringbuffer.appendvalueordash ( Httpaccountinginfo.getremoteuser ()); } }
Reference:
weblogic.servlet.logging
Interface Customelflogger
This is a interface which allows customers to add custom information to the Extendedlogformat. They'll is responsible for implementing Logfield (Httpaccountinginfo metrics) method. ELF allows users to the Specify fields to is logged with each HTTP request. One of these #Fields are an application specific field in the form of X-somefieldname WLS expects a fully qualified Classna Me as the argument for this field and attempts to instantiate a instance of this class. Customers are responsible for following formatting guidlines of the specification. For example if they with 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" API provides them the opportunity to do Anthying they want basically and they should not doing something that would inordinantly slow the system down. Like looking something up in the dmbs, or doing signigicant IO or networking
Key classes:
Weblogic.servlet.logging.LogManagerHttp
Weblogic.servlet.logging.ELFLogger
Weblogic.servlet.logging.CLFLoggerLogFormat