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

Announcements

News and Announcements icon
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,255 Moderator 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,255 Moderator 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 227

#2
David_MA Profile Picture

David_MA 204 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 177

Last 30 days Overall leaderboard