web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create A log for unatt...
Power Automate
Unanswered

Create A log for unattended flow

(0) ShareShare
ReportReport
Posted on by 32

Hi, How do you guys create a log for an unattended bot? I found here in the community to take screenshots of every step, what if I want to know the value of the variable? How can I do that?

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    Deenuji_0-1690545705183.png

    Hi, usually we use "write text to file" action for capturing the variables values kind of log file for our bots in unattended mode as mentioned in the screenshot and this would be very useful for us to backtrack our flow activities in case of any issues. 

  • IamNadaa Profile Picture
    32 on at

    Hi, so meaning every step should I add Write text to the file?

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    Hi,

    Indeed, you can include this action wherever you wish to record the variable values. Once your unattended run is finished, you can review the log file to see the values held by the variables during the actual execution.

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up. Thank you.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    I would suggest having a separate sub-flow that logs whatever you want into a pre-defined text file. And then call that sub-flow when you want to log anything.

    I would suggest watching this video: https://www.youtube.com/watch?v=QjrxLPg_TdI It covers best practices for PAD developers. While I personally do not agree with some of what the author suggests there, he does cover a rather okay'ish way of logging. 

     

    A very simplified Log sub-flow could look like this:

    Agnius_0-1690603107034.png

    Here's a snippet that you can copy and paste into PAD:

    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyy-MM-dd HH:mm:ss''' Result=> TimeStamp
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyy-MM-dd''' Result=> DateStamp
    File.WriteText File: $'''C:\\RPA\\%ProjectName%\\Logs\\%ModuleName% %DateStamp%.log''' TextToWrite: $'''%TimeStamp%: %Log_Message%''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.UTF8

    I would then have another sub-flow that gets the last error like this:

    Agnius_1-1690603173371.png

    And then I would encapsulate my code in an On block error action that calls both of those sub-flows on error:

    Agnius_2-1690603212359.png

    While for normal non-error messages, I'd simply call the LogToFile sub-flow whenever I want to log anything:

    Agnius_3-1690603264438.png

     

    That is basically the recommended sequence for logging in PAD, but then you can choose what type of files to use. The above is a simplified version I use in demos, while in PROD I would normally do a JSON-formatted log. Some people prefer CSV instead.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard