Showing posts with label PeopleSoft logging. Show all posts
Showing posts with label PeopleSoft logging. Show all posts

Friday, September 7, 2007

Log4j in PeopleCode

Jim's PeopleSoft Journal had a good entry on using Log4j in PeopleCode. This first article assumed that you would have control over the log4j.properties file in your environment. Jim also posted a follow-up on Log4j and Peoplecode Part II where he discussed how to programmatically configure the logging. This is nice for those, like me, that do not have access to modify the $PS_HOME/appserv/classes/log4j.properties file.

The programmatic approach works well, but I didn't want to hardcode all that information in each event I want to log information in. You can point log4j to an alternative logging file using the code below, that way you can keep control of the logging level and setup of the appenders in a file that is easy to modify. Of course, this assumes that in your environment you have some access to a directory where you can store the file and grant write access to it for the daemon that runs the application server.


Local JavaObject &log4jConfig = GetJavaClass("org.apache.log4j.PropertyConfigurator");

&log4jConfig.configure("/some/directory/log4j.properties");

Local JavaObject &log = GetJavaClass("org.apache.log4j.Logger").getLogger("edu.csufresno.cis.HRS_CE_RESUME.PageActivate");

&log.info("hi from peoplecode");


Note: I got tripped up initially because I didn't read Jim's code closely enough and tried using CreateJavaObject out of habit instead of GetJavaClass. Since both methods are static (i.e., can't create an instance of a Logger) it blew up with an error.