Write Custom Messages to PeopleSoft Trace File to Help Debugging ?

PeopleSoft Trace provides a lot useful information to find the bugs, issues and understand the application state. The main problem with this is it provides a so much of information that it hardly gets used completely.

PeopleSoft Trace is not very reader friendly, with a lot of information overload. How can we debug the code provide the details of the critical variable values. Many Application Framework come with support for the Custom Logging capability.

Application Logging is very much different for what we use "WinMessage" to debug and get the values of the variables. The main problem with this is every time you have to remove the code for winmessage and add the code back when you want to debug the same PeopleCode. What if you had switch to control the "Winmessage" like debug statements work only when it is required and not always. ??  Welcome to "Application Logging".
Application Logging is the answer for this and there is 2 options that we can use withe PeopleSoft (Atleast for my knowledge).

How can you achieve this in the PeopleSoft?
1) PeopleSoft do have one which can use for the Application Log facility. Application logging enables you to do error logging using an independent application log fence mechanism. It also enables you to write to the PeopleTools log using the WriteToLog built-in function
In PeopleTools, a log fence is a type of barrier. Application error messages are only written to the PeopleTools log if the log fence setting that the messages are written to the log with (using WriteToLog) is less than or equal to the current application log fence setting (AppLogFence) in the application server configuration file (PSAPPSRV.CFG ).
Following document will explain in more detail about this.
2) We do have custom method that we can use for the logging the application. Custom method - well not really custom method, we basically using the JavaAPI - Log4J - is an standard Logging method for the Java based applications. Since PeopleSoft supports the Java we can use this mechanism to get the application log.
Since it's framework and works with Java - Any version of the PeopleSoft can adapt to this method.
You can configure the log level, targets, and layouts from a configuration file without touching your production code. You can change the Log Level using the Peoplecode Dynamically.

You can get more information about this in the below link, where Jim has explained about the Log4J method.