# Is there a better way to monitor a log file?

**URL:** https://discourse.julialang.org/t/is-there-a-better-way-to-monitor-a-log-file/74538
**Category:** Performance
**Created:** [January 13, 2022, 10:42am UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-monitor-a-log-file/74538 "2022-01-13T10:42:09Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![anon69491625](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@anon69491625](https://discourse.julialang.org/u/anon69491625)
#### Post date: [January 13, 2022, 10:42am UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-monitor-a-log-file/74538/1 "2022-01-13T10:42:09Z")

</div>

Hi all  
new to julia and so still learning the basics. I have a log file that another system updates about every 1 second. It’s just a simple text file and each “row” is about 1k bytes. I just want to get the “updates” so I thought to just check every 0.5 second.

**Right now I have this working BUT is there a better way?**

```julia
file = open("the_log_file.log")
seekend(file) # keep sniffing the last entry only.

while true
    sleep(0.5)
    data = read(file, String)
    !isempty(data) && print(data)
end 

```

Thank you

---

<div class="post-metadata">

### Author: ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)
#### Post date: [January 13, 2022, 11:47am UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-monitor-a-log-file/74538/2 "2022-01-13T11:47:54Z")

</div>

Maybe not work your looking for (since it doesn’t involve Julia) but there is [`tail -f the_log_file.log`](https://linux.die.net/man/1/tail).

---

<div class="post-metadata">

### Author: ![anon69491625](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@anon69491625](https://discourse.julialang.org/u/anon69491625)
#### Post date: [January 13, 2022, 12:01pm UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-monitor-a-log-file/74538/3 "2022-01-13T12:01:47Z")

</div>

Hey @carstenbauer

thanks for the interest. You are right, I want to keep this inside Julia so I can get a better idea about the internals. I did consider calling the tail function and it makes a lot of sense but for now I’d like to use this goal to learn more about how Julia works.

thanks for the suggestion though.

---

<div class="post-metadata">

### Author: ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)
#### Post date: [January 13, 2022, 12:29pm UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-monitor-a-log-file/74538/4 "2022-01-13T12:29:23Z")

</div>

You probably want the [FileWatching](https://docs.julialang.org/en/v1/stdlib/FileWatching/) stdlib.

---

<div class="post-metadata">

### Author: ![anon69491625](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@anon69491625](https://discourse.julialang.org/u/anon69491625)
#### Post date: [January 13, 2022, 12:47pm UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-monitor-a-log-file/74538/5 "2022-01-13T12:47:28Z")

</div>

hi there  
@oxinabox  
Thanks for another great suggestion. I am trying to get a laundry list of things to try. There are many ways to get this done I’m looking for the most sensible.
