Store log details in variable or database

Looking for a way to get the execution log details stored into a variable or database without having the read the execution log file. For example the execution log has a fingerprint and a job Id for each log message. I would like to assign those to a variable for use later on. Are the details of an execution log accessible within studio or would I have to read from the log file? Example log below, personal details redacted:

11:06:46.6274 Info {
“message”:“UiPath Examples execution started”,
“level”:“Information”,
“logType”:“Default”,
“timeStamp”:“2022-03-16T11:06:46.6254888-05:00”,
“fingerprint”:“0cf86ce2-357a-45cf-bd23-2440b5019173”,
“windowsIdentity”:"",
“machineName”:"",
“fileName”:“Get Mail”,
“initiatedBy”:“Studio”,
“processName”:“UiPath Examples”,
“processVersion”:“1.0.0”,
“jobId”:“0eac5feb-143d-45d5-af24-2a07ceeb77a5”,
“robotName”:"",
“machineId”:,
“organizationUnitId”:
}

I think that in UiPathStudio configuring the NLog settings, possibly app.config, adding a new Target setting a database could be achieved.

refer: DatabaseTarget Class

@lepumin

I believe NLog.conf is the correct config file for those settings. My issue is trying to split the details of the log so they can be assigned to columns in a table. Here’s the line to change the details of what is logged:

${message} contains the details that I want (fingerprint, job id, date, etc), but I don’t know how to split those.

<target type="File" name="WorkflowLogFiles" fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log" layout="${time} ${level} ${message}" keepFileOpen="true" openFileCacheTimeout="5" concurrentWrites="true" encoding="utf-8" writeBom="true" />

After much research I don’t believe you are able to grab those details by editing the nlog.config file, they would have to be pulled out of the outputted log file. For anyone seeking to do something similar, here is my use case and my solution.

Use case: Log the start of an automation, any successful loops, errors, exceptions, and the end of an automation. These logs are stored in a local SQL Server database.

Prior to logging, store the variables you wish to log into variables.

For fingerprint I create a new guid using the assign activity:

ProcessName and ProcessVersion can be grabbed using get job info and assign activities:



Exception messages are tricky. I use the global handler and copy the exception message to the clipboard inside the global handler (you could also use an asset, but clipboard is easier and does what I want). Then I get the copied text and store it into a variable in the main workflow. Make sure to clear the variable containing the exception message at the start of each of each loop.


image

Everything else I could get using assign activities. I then pass these variables into a stored procedure that logs those into the table I have setup for UiPath logging.

Hope this helps someone else trying to do something similar!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.