- Create an extended logger by compiling the code below and creating a jar ( el.jar in this example)
import weblogic.servlet.logging.CustomELFLogger;
import weblogic.servlet.logging.FormatStringBuffer;
import weblogic.servlet.logging.HttpAccountingInfo;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
public class PPCustomField implements CustomELFLogger
{
public void logField(HttpAccountingInfo metrics,
FormatStringBuffer buff) {
buff.appendValueOrDash(metrics.getHeader(“Cookie”));
Map<String, String> map = new HashMap<String, String>();
StringBuffer sbuf = new StringBuffer();
Enumeration headerNames = metrics.getHeaderNames();
while (headerNames.hasMoreElements()) {
String key = (String) headerNames.nextElement();
String value = metrics.getHeader(key);
sbuf.append(key+”:”+value+”n”);
}
int length = sbuf.toString().length();
System.out.println(“headers==”+sbuf.toString());
System.out.println(“length==”+length);
buff.appendValueOrDash(” Req-Header-Length:”+String.valueOf(length));
}
}
2. / Go to domain bin folder
/x/bea-wl1213/user_projects/domains/<domain>/bin
3. Create a script with the name below.
setUserOverrides.sh
4. Set the PRE_CLASSPATH variable to the location of the extended logger JAR.
export PRE_CLASSPATH=/x/bea-wl1213/user_projects/domains/<domain>/el.jar
el.jar is the extended logger jar.
5. Go to Home >Summary of Servers > servername > Logging > HTTP ( Advanced) and change the Format to extended and provide the format fields.
6. Restart the JVM and check the access log of the JVM.
7. Check Entry in logs
JSESSIONID=8OTYD-98RbnwDmChUGx61TW20AfC_DbjA6775PT7YewummUh0YYw!-1884316704 Req-Header-Length=415 2019-08-28 04:50:45 0.008 GET /prsysmgmt/js/expcollapse.js 200
Reference