Skip to content

Instantly share code, notes, and snippets.

@iversond
Last active April 1, 2021 20:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iversond/1fe465f7b0ba307d0915aa5de335de90 to your computer and use it in GitHub Desktop.
Save iversond/1fe465f7b0ba307d0915aa5de335de90 to your computer and use it in GitHub Desktop.
WebLogic HTTP Header to log OPRID for PeopleSoft pages to the access log (from @ripleymj).
import weblogic.servlet.logging.CustomELFLogger;
import weblogic.servlet.logging.FormatStringBuffer;
import weblogic.servlet.logging.HttpAccountingInfo;
import java.lang.reflect.Method;
public class OPRIDLogField implements CustomELFLogger
{
public void logField(HttpAccountingInfo metrics, FormatStringBuffer buff)
{
Object psperfenv = metrics.getAttribute("psperfenv");
if(psperfenv != null)
{
try
{
Method getOperID = psperfenv.getClass().getMethod("getOPERID");
buff.appendValueOrDash(getOperID.invoke(psperfenv).toString());
}
catch(Exception e)
{
buff.appendValueOrDash("exception");
}
}
}
}
@iversond
Copy link
Author

The log field is named x-OPRIDLogField.
To compile: javac -cp weblogic.jar OPRIDLogField.java && jar cf olf.jar OPRIDLogField.class
Copy the OPRIDLogField.jar to a folder on the web server and add the path the CLASSPATH option in setEnv.

@ripleymj
Copy link

ripleymj commented Dec 2, 2016

I should probably take the blame for this, instead of @ripley. When I was working on this, putting the jar in psft/pt/8.55/webserv/peoplesoft/lib/ keeps you from having to modify setEnv. @iversond also pointed out that this relies on having the PPM agent enabled on the web server.

@iversond
Copy link
Author

@ripleymj - fixed the attribution in the description :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment