# Search in TXT log file for a piece of text

**URL:** <https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248>\
**Category:** General\
**Created:** [17 March 2020 21:12 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248 "2020-03-17T21:12:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogier](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@rogier](https://discourse.nodered.org/u/rogier)\
**Post date:** [17 March 2020 21:12 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248/1 "2020-03-17T21:12:12Z")

</div>

I have a .txt logfile and want to search in the file for a piece of text.  
If the text is in the file i like a true output and not a false output

i found and tried this flow but always displays false... does anyone know what's wrong?

[https://flows.nodered.org/flow/1e5f25206fadb339293e879f397fa513](https://flows.nodered.org/flow/1e5f25206fadb339293e879f397fa513)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 March 2020 21:18 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248/2 "2020-03-17T21:18:54Z")

</div>

Please take note of the pinned message and put your code between triple back-ticks. As it is, it is unusable. Thanks.

As I think you are using a function node to do the search (?), it may be easier just to show that code separately.

---

<div class="post-metadata">

**Author:** ![rogier](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@rogier](https://discourse.nodered.org/u/rogier)\
**Post date:** [17 March 2020 21:30 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248/3 "2020-03-17T21:30:57Z")

</div>

i'm sorry, i changed my massage and put the url in it..

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c711b374068667d1012f77e0939f9eb081241886.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a5e09065027ce003d3c8edfcbb340cb670ff6c8e.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6e0ab5d5fa1c8f32bacf9f8069876b2eb430b802.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c187ffed04ecdd06917dcfa29c71104e4b074c69.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [19 March 2020 12:37 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248/4 "2020-03-19T12:37:21Z")

</div>

Can you post the logfile somewhere (or post some example lines) and the string you are trying to find ?

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [19 March 2020 13:42 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248/5 "2020-03-19T13:42:03Z")

</div>

To check if element exists in array use  
`yourArray.indexOf(element) != -1`

What you are doing currently is the check if the entry is in array and is not first element of that array

---

<div class="post-metadata">

**Author:** ![dathor](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@dathor](https://discourse.nodered.org/u/dathor)\
**Post date:** [20 March 2020 00:48 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248/6 "2020-03-20T00:48:21Z")

</div>

why not use a switch node?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e306b16c4a02699de6c1c5057045756755e57ee1.png)

---

<div class="post-metadata">

**Author:** ![rogier](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@rogier](https://discourse.nodered.org/u/rogier)\
**Post date:** [23 March 2020 09:23 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248/7 "2020-03-23T09:23:20Z")

</div>

sometimes it is too simple for words and I think too difficult ... thank you ! it works..

---

<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:** [6 April 2020 09:23 UTC](https://discourse.nodered.org/t/search-in-txt-log-file-for-a-piece-of-text/23248/8 "2020-04-06T09:23:20Z")

</div>

Closed on 6 April 2020 09:23 UTC

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