Posted: 9 May 2016 14:05 EDT Last activity: 25 May 2016 13:00 EDT
Custom Appender - Thread Info
We have written a Custom Appender. We loaded the JAR into PRPC, updated prlogging.xml and able to create a new log file altogether. Now, we want to read data from a clipboard page / page list / database table rule from our custom Java Appender Code. How can we do this? What is the starting point?
We have error message, severity etc. info in LogEvent. How to find out the thread, user, application name when a log event occurs?
Any help is much appreciated. Thanks in advance.
Message was edited by: Marissa Rogers - Updated category
Thanks for your reply. What you suggested works when I am connected to the browser. I want to read this information from Custom Java Appender.
Whenever an exception/error occurs, Pega is giving control to the custom Java Appender (Custom JAR). From Custom Java Appender, I want to know thread info, application name, query records from database rule, invoke/call PRPC rules, read Clipboard pages etc. How can I achieve this?
Thanks for your response. That solves my problem to some extent. I also have the need to invoke PRPC rules from Custom Java Appender. For this, I need PegaAPI or PublicAPI instantiation which is done as mentioned in my above replies. How can I achieve this?
We have multiple applications running in PROD. Based on the application which caused Error/Exception, we want to push some application specific data/values to be pushed into logs for our critical reporting needs. We maintain this application specific info in a Data Type rule (Database table). At the same time, we want to read some data from the User's clipboard pages / System level Clipboard pages whenever an Error/Exception is caused by an Operator. This is also for supporting for our critical reporting needs.
That's why, in short, I mentioned as "How to invoke PRPC rules" which could have caused some confusion. I hope this clarifies.
2. You have already got this working from PRPC (which uses a customized version of log4j): I think ?
3. You want this Appender to 'reach into' PRPC and execute some rules; and get the information returned ?
Here's what I'm unsure about:
When you say:
We have multiple applications running in PROD. Based on the application which caused Error/Exception, we want to push some application specific data/values to be pushed into logs for our critical reporting needs
I assume you mean 'PRPC applications' here.
So I think you are saying that if a PRPC Application Error occurs; you need to capture additional PRPC-specific information relating to the PRPC Clipboard etc ?
Do you mean in the same way that PRPC Alerts (which also use log4j) contain PRPC-specific information ?
You seem to have a secondary and (as far as I can see, separate) requirement:
At the same time, we want to read some data from the User's clipboard pages / System level Clipboard pages whenever an Error/Exception is caused by an Operator.
Do you mean you literally need to 'call-back' to PRPC and request further information here ?
If so: this sounds (in theory) acheivable by using PRPC 'Services' - say a SOAP Service, or a REST Service ?
It doesn't sound a good idea to me (I could be wrong) to make SOAP/REST calls *from* a log4j appender to a service though: not least because of the latency that would cause.
(Appenders should be *writing* somewhere really; in theory they could do *anything* that you can do in Java, but do you really want to use an Appender to do this ? It sounds like 'feature-creep' ?, dunno)
Perhaps you could illustrate what you need here in your Log Files: exactly what PRPC information you need in the output ?
I meant multiple PRPC applications by referring to many applications in PROD
PRPC Specific Information :
Yes John, your understanding is right. Whenever an error occurs, we want additional PRPC-specific information which we may wish to read from PRPC Clipboard (User, System pages etc.) or Data Type rules i.e. mapped to a DB Table. Yes, just like PRPC Alerts (we see very limited information)
Call-back to PRPC :
Yes, I meant 'Call-Back' to PRPC and request further information. SOAP / REST service can be used by relying purely on JAVA API but leveraging PRPC PublicAPI / PegaAPI i.e. tools object initialization provides better control to call/execute PRPC rules.
For each PRPC application, we have our environment specific properties, business specific properties maintained in a DB Table / Data Type rule. We also have a reporting tool which can report on a log file with it's own specific format i.e. Key Value Pair format. This reporting tool needs additional properties to be present in the log file which we can only get from either Clipboard OR by executing/calling PRPC rules from Custom Log Appender whenever an Error / Exception occurs.
I hope this clarifies. If not, please let me know.
Access the database table and clipboard to write one single log entry to a file may take time to complete, in the mean time the Application will continue to write log entries, there is a chance that the log4j buffer size may need to be increased to accommodate the log entries while you fetch additional data for the first one. this doesn't seems scalable approach, and may have chance to loose logentry in case db query fails.
Instead of a database table, you could store the information in LogContext map
you could add new fields and corresponding data in LogContext using LogContext.put("newfield1", "myFielddata");
and write the data in the log by using a log pattern like below, you could use the existing appender here.