How to pass custom values from C# script to reflect in runtime logs / studio logs in Pega Studio 22 version? Please help at the earliest in this regard.
@PraneshP9696 In 22.1, whenever you create a new script container, the following lines will be included to assist you in writing to logs within that script. Here they are in case you have deleted them. These get added to all new script containers, so if you do forget, you may create a new script to copy these out and delete it.
using ScriptLogger = Pega.Core.Script.ScriptLogger;
#region Logging examples
// ScriptLogger.LogDebug(“test”);
// ScriptLogger.LogInformation(“test”);
// ScriptLogger.LogWarning(“test”);
// ScriptLogger.LogError(“test”);
// ScriptLogger.LogException(exception);
// ScriptLogger.LogException(exception, “test”);
#endregion
@ThomasSasnett Thanks for the reply, Thomas. I tried the same with all of the log types. (I have kept both studio and runtime log level at “Debug”) but they are not appearing in runtime logs post code run. In previous version (19.1.75), we used to write custom logs in C# script, using the syntax “OpenSpan.Diagnostics.Diagnostic.TraceVerbose(“Script”, “my custom value”);” and it was perfectly working. With the new version, I tried all of the above mentioned by you but still not seeing the values in runtime logs.
@PraneshP9696 I suspect you do not have logging enabled. If you are running from Studio, check your log settings under Tools–>Options–>Runtime diagnostics and ensure logging is enabled and set to DEBUG. If you are logging to a lower level and have logging set to a higher level, logs will be written, however if your log level is set to ERROR, then no higher log messages will be written.
If you are using standalone Runtime, then check your PegaRuntimeConfig.xml and ensure that logging is enabled and set to the appropriate level for all categories (4 = debug, 3 = Info, etc.).
@ThomasSasnett Thanks for the reply Thomas. I am getting logs now. We have so many cross-references in our old solution including project references among different projects. So trying to get an overall picture of the new version. Thanks for your help in this regard.
@PraneshP9696 You’re welcome. I am happy to help.