# How do I write to log\_history.txt file?

**URL:** <https://forum.universal-robots.com/t/how-do-i-write-to-log-history-txt-file/5252>\
**Category:** Java\
**Created:** [October 3, 2019, 7:56am UTC](https://forum.universal-robots.com/t/how-do-i-write-to-log-history-txt-file/5252 "2019-10-03T07:56:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon54635303](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@anon54635303](https://forum.universal-robots.com/u/anon54635303)\
**Post date:** [October 3, 2019, 7:56am UTC](https://forum.universal-robots.com/t/how-do-i-write-to-log-history-txt-file/5252/1 "2019-10-03T07:56:32Z")

</div>

Hello,

I am working on a program where I want to log suggested acceleration speed by writing to log\_history.txt everytime the play button is pressed.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)\
**Post date:** [October 3, 2019, 11:43am UTC](https://forum.universal-robots.com/t/how-do-i-write-to-log-history-txt-file/5252/2 "2019-10-03T11:43:36Z")

</div>

Hi Luan,

You can use the “textmsg(s1, s2=’ ')” function:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/e/e2bb83744da16144d7f54541c48d11ad059b62d2.png)

To add to the log file.

If you insert it into the preamble it will add every time you start the program pushing the play button.

---

<div class="post-metadata">

**Author:** ![anon54635303](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@anon54635303](https://forum.universal-robots.com/u/anon54635303)\
**Post date:** [October 4, 2019, 8:55am UTC](https://forum.universal-robots.com/t/how-do-i-write-to-log-history-txt-file/5252/3 "2019-10-04T08:55:10Z")

</div>

Thank you!

It now writes the suggested acceleration in log\_history.txt, but now I have a different problem.

It writes the acceleration multiple times. Everytime the program goes over the ProgramNodeContribution where I wrote the script in, it writes the acceleration in the log file. Is there a way to only make it write once?

I have tried inserting the script in InstallationNodeContribution, but I don’t know how to gain the specific data/datamodel the ProgramNodeContribution and Contribution has.

---

<div class="post-metadata">

**Author:** ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)\
**Post date:** [November 1, 2019, 2:34pm UTC](https://forum.universal-robots.com/t/how-do-i-write-to-log-history-txt-file/5252/4 "2019-11-01T14:34:14Z")

</div>

You don’t have access to ProgramNodes data model. You could program some logic so every program node only logs it the first time it is executed in that program executed.  
I am not sure the overall target is completely clear to me yet.

---

<div class="post-metadata">

**Author:** ![anon54635303](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@anon54635303](https://forum.universal-robots.com/u/anon54635303)\
**Post date:** [November 8, 2019, 10:51am UTC](https://forum.universal-robots.com/t/how-do-i-write-to-log-history-txt-file/5252/5 "2019-11-08T10:51:16Z")

</div>

Is there a way to gain access to ProgramNodes data model from InstallationNode? Or is there a way to make an EventListener on ursim/urcap playbutton?
