Can we create a file of the logs that are created in debug?


#1

Hi,

I am a beginner at Uipath using Trial version.
I want to get the log of all the activities taking place throughout my project.
Using debug I am getting it. But can I get it in a separate file without using Log Message?
Is it possible?

Thanks!


#2

Yes, if you accept that WriteLine will be paired with it. Since for normal logging LogMessage should be used I don’t think it’s a big downside. Key is to know that debug execution messages (activity executing, ended etc.) is Trace level.

Edit the NLog.config in your Studio location file.

Add a separate target (name the file how you want):
<target xsi:type="File" name="traceLogFile" fileName="${LogDirectory}/${shortdate}_TraceLog.log" layout="${time} ${level} ${message}" concurrentWrites="true" />

Edit the rules (first line is added, second is altered - note that final=“True” was removed):
<logger name="Execution" minLevel="Trace" maxLevel="Trace" writeTo="traceLogFile" /> <logger name="Execution" minLevel="Info" writeTo="executionFile" />

What this will make is:
Everything from Execution logger (default when robot is running, be it from Studio or otherwise) that has exactly Trace level will be logged to traceLogFile target. You could even change it to have only maxLevel, so you split it in half, but by default messages with lower level than Trace should not be logged unless you’re debugging the Studio application itself (not likely).
Everything from Info level and up (Info, Warn, Error, Fatal) will be stored in the executionFile target.

Test it and see if it fits your needs.

As a sidenote - you can add more targets/rules as you see fit (they don’t need to be files either). We’ve found it very useful to have a separate log file with minLevel=“Warn” or “Error”, depending on specifics, to be able to easily see if something errored out that could be missed (f.e. some operation succeeds only after retrying - easy to miss since the whole process goes fine, but there’s a high chance for improvement to be done there).

PS. Do note that if you change logging level via UiPath tray settings, it may alter NLog.config. Haven’t tested it.

Regards.


System.io library classes not working properly