# Create and display log in dashboard

**URL:** https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384
**Category:** Dashboard
**Created:** [18 December 2022 15:57 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384 "2022-12-18T15:57:41Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Kimovitzh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kimovitzh/32/67046_2.png) [@Kimovitzh](https://discourse.nodered.org/u/Kimovitzh)
#### Post date: [18 December 2022 15:57 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/1 "2022-12-18T15:57:41Z")

</div>

Hi.

What appears to be what I want is in the last post in this thread:

> [@Help with displaying text log](https://discourse.nodered.org/t/help-with-displaying-text-log/37333/5):
>
> Thanks for all the reply's! Thought id share the flow for others benefit Result [image]

Unfortunately the guy who posted this isn't replying.

What I want is to have a true and false signal being logged and saved and then displayed on the dashboard.  
Then I can see when the door has been opened and when the door bell has been used.

I can see the nodes used but what's happening in the nodes is the question.

//Kim

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [18 December 2022 17:11 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/2 "2022-12-18T17:11:12Z")

</div>

If you add those nodes to your flow and connect it to your data source, it should more or less work as is.

The simple time node adds msg properties for the current time, which you can then use as a time stamp for the log.

The switch / function nodes are likely used to format the text so it looks nice in the log.

The file out node stores this information in to a file of your choosing.

The file watch node checks to see if something has been added to the log file, and if it has then it triggers the exec node which is running a **tail** command on the file (which outputs the last lines of the log).

This then goes to the template node to display the info on the dashboard.

Set it up and have a go 😉

If you get stuck then you can ask for specific help.

---

<div class="post-metadata">

### Author: ![Kimovitzh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kimovitzh/32/67046_2.png) [@Kimovitzh](https://discourse.nodered.org/u/Kimovitzh)
#### Post date: [19 December 2022 10:21 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/3 "2022-12-19T10:21:57Z")

</div>

I tied and I just get stuck.  
I have no clue for the function node. I would have used a template node to combine the simpletime and the payload for "on/off" - but there's probably someting to combine or instruct the save file node.

 ![Skærmbillede 2022-12-19 kl. 11.21.34](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/8/78d397d89f88800cae7659b3d9fe920f344f1ba1.png)

---

<div class="post-metadata">

### Author: ![Kimovitzh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kimovitzh/32/67046_2.png) [@Kimovitzh](https://discourse.nodered.org/u/Kimovitzh)
#### Post date: [19 December 2022 14:31 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/4 "2022-12-19T14:31:08Z")

</div>

Ok so I got it to work 90%.

 ![Skærmbillede 2022-12-19 kl. 15.25.57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/477a48fb30c6dafb0b28951ffff4bea04c7ad1a0.png)

So the file writing, saving and **tail** function is good.  
Now it's just a matter of displaying it the right way.

As you all can see, the output is cluttered. Could anyone give Information on how to organize the output in the dashboard?

I've tried to reuse this code, but I don't fully understand how it works.

 ![Skærmbillede 2022-12-19 kl. 15.26.11](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/0994a24b45a8c6ddebaf8c2b22bba60831c6d025.png)

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [19 December 2022 16:06 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/5 "2022-12-19T16:06:45Z")

</div>

> [@Kimovitzh](#):
>
> As you all can see, the output is cluttered

I cannot see that ?

Can you post your flow? Export the nodes in the editor, copt to clipboard and then in message press ctrl E then paste.

---

<div class="post-metadata">

### Author: ![Kimovitzh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kimovitzh/32/67046_2.png) [@Kimovitzh](https://discourse.nodered.org/u/Kimovitzh)
#### Post date: [19 December 2022 16:18 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/6 "2022-12-19T16:18:23Z")

</div>

Forgot to add the picture:

 ![Skærmbillede 2022-12-19 kl. 15.25.47](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/708fc5b9a412410ce0ce99d49a9e4d0db11877cb.png)

Flow:

```auto
[{"id":"5e7af029d7f474a9","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":300,"wires":[["a3ef769b309faf9f"]]},{"id":"7dce200972e248aa","type":"debug","z":"a59677cc44057423","name":"debug 116","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":340,"wires":[]},{"id":"d799e3f4ab703c50","type":"simpletime","z":"a59677cc44057423","name":"","mydate":true,"myymd":true,"myyear":true,"mymonth":true,"mymonthn":true,"mydom":true,"mydoy":true,"myday":true,"myhourpm":true,"myhour":true,"mytime":true,"mytimes":true,"myminute":true,"myminutes":true,"mysecond":true,"mymillis":true,"myepoch":true,"myrawdate":true,"mypm":true,"x":470,"y":240,"wires":[["4ba5f0c5cbe4dccc"]]},{"id":"6e5b2cb9e5a0c875","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":310,"y":200,"wires":[["d799e3f4ab703c50"]]},{"id":"3be0a903267eabb8","type":"exec","z":"a59677cc44057423","command":"tail -n 4 ~/TestFile.txt","addpay":"","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"","x":700,"y":360,"wires":[["7dce200972e248aa","f03fce73fb7471d5"],[],[]]},{"id":"9229c3a4974c9be5","type":"file","z":"a59677cc44057423","name":"","filename":"~/TestFile.txt","filenameType":"str","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1030,"y":240,"wires":[[]]},{"id":"a3ef769b309faf9f","type":"file in","z":"a59677cc44057423","name":"","filename":"~/TestFile.txt","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":470,"y":300,"wires":[["a5929dca97db8d57","3be0a903267eabb8"]]},{"id":"a5929dca97db8d57","type":"debug","z":"a59677cc44057423","name":"debug 147","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":420,"wires":[]},{"id":"3cead93eaa25f41f","type":"template","z":"a59677cc44057423","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{mydom}}/{{mymonthn}}-{{myyear}}.{{mytimes}}-{{payload}}","output":"str","x":840,"y":240,"wires":[["9229c3a4974c9be5"]]},{"id":"60c3c3628b903a22","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":310,"y":240,"wires":[["d799e3f4ab703c50"]]},{"id":"4ba5f0c5cbe4dccc","type":"change","z":"a59677cc44057423","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"Test ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"Test OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":240,"wires":[["3cead93eaa25f41f"]]},{"id":"f03fce73fb7471d5","type":"ui_template","z":"a59677cc44057423","group":"6c1f9d4984a3f2d6","name":"","order":1,"width":10,"height":7,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":960,"y":300,"wires":[[]]},{"id":"6c1f9d4984a3f2d6","type":"ui_group","name":"Default","tab":"463f26aa73519adc","order":1,"disp":true,"width":10,"collapse":false,"className":""},{"id":"463f26aa73519adc","type":"ui_tab","name":"Test","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [19 December 2022 16:34 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/7 "2022-12-19T16:34:35Z")

</div>

Change your UI template to  
`<div style="white-space: pre-wrap;" ng-bind-html="msg.payload"></div>`

---

<div class="post-metadata">

### Author: ![Kimovitzh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kimovitzh/32/67046_2.png) [@Kimovitzh](https://discourse.nodered.org/u/Kimovitzh)
#### Post date: [19 December 2022 17:13 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/8 "2022-12-19T17:13:40Z")

</div>

> [@Sean-McG](#):
>

That did the trick!  
Thanks 🙏

The complete flow is:

```auto
[{"id":"5e7af029d7f474a9","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":300,"wires":[["a3ef769b309faf9f"]]},{"id":"7dce200972e248aa","type":"debug","z":"a59677cc44057423","name":"debug 116","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":340,"wires":[]},{"id":"d799e3f4ab703c50","type":"simpletime","z":"a59677cc44057423","name":"","mydate":true,"myymd":true,"myyear":true,"mymonth":true,"mymonthn":true,"mydom":true,"mydoy":true,"myday":true,"myhourpm":true,"myhour":true,"mytime":true,"mytimes":true,"myminute":true,"myminutes":true,"mysecond":true,"mymillis":true,"myepoch":true,"myrawdate":true,"mypm":true,"x":470,"y":240,"wires":[["4ba5f0c5cbe4dccc"]]},{"id":"6e5b2cb9e5a0c875","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":310,"y":200,"wires":[["d799e3f4ab703c50"]]},{"id":"3be0a903267eabb8","type":"exec","z":"a59677cc44057423","command":"tail -n 4 ~/TestFile.txt","addpay":"","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"","x":700,"y":360,"wires":[["7dce200972e248aa","f03fce73fb7471d5"],[],[]]},{"id":"9229c3a4974c9be5","type":"file","z":"a59677cc44057423","name":"","filename":"~/TestFile.txt","filenameType":"str","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1030,"y":240,"wires":[[]]},{"id":"a3ef769b309faf9f","type":"file in","z":"a59677cc44057423","name":"","filename":"~/TestFile.txt","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":470,"y":300,"wires":[["a5929dca97db8d57","3be0a903267eabb8"]]},{"id":"a5929dca97db8d57","type":"debug","z":"a59677cc44057423","name":"debug 147","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":420,"wires":[]},{"id":"3cead93eaa25f41f","type":"template","z":"a59677cc44057423","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{mydom}}/{{mymonthn}}-{{myyear}}.{{mytimes}}-{{payload}}","output":"str","x":840,"y":240,"wires":[["9229c3a4974c9be5"]]},{"id":"60c3c3628b903a22","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":310,"y":240,"wires":[["d799e3f4ab703c50"]]},{"id":"4ba5f0c5cbe4dccc","type":"change","z":"a59677cc44057423","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"Test ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"Test OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":240,"wires":[["3cead93eaa25f41f"]]},{"id":"f03fce73fb7471d5","type":"ui_template","z":"a59677cc44057423","group":"6c1f9d4984a3f2d6","name":"","order":1,"width":10,"height":7,"format":"<div style=\"white-space: pre-wrap;\" ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":960,"y":300,"wires":[[]]},{"id":"6c1f9d4984a3f2d6","type":"ui_group","name":"Default","tab":"463f26aa73519adc","order":1,"disp":true,"width":10,"collapse":false,"className":""},{"id":"463f26aa73519adc","type":"ui_tab","name":"Test","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [2 January 2023 17:14 UTC](https://discourse.nodered.org/t/create-and-display-log-in-dashboard/72384/9 "2023-01-02T17:14:03Z")

</div>

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