# Something like flush function for logger?

**URL:** <https://erlangforums.com/t/something-like-flush-function-for-logger/2664>\
**Category:** Questions / Help\
**Tags:** erlang, logger, escript\
**Created:** [June 6, 2023, 3:04pm UTC](https://erlangforums.com/t/something-like-flush-function-for-logger/2664 "2023-06-06T15:04:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuna.prime](https://erlangforums.com/letter_avatar_proxy/v4/letter/k/b77776/32.png) [@kuna.prime](https://erlangforums.com/u/kuna.prime)\
**Post date:** [June 6, 2023, 3:04pm UTC](https://erlangforums.com/t/something-like-flush-function-for-logger/2664/1 "2023-06-06T15:04:11Z")

</div>

I’m building escript and using logger but i have noticed that if my script finishes too fast not all log information is printed (either in terminal or in a log files). Currently i’m working around this problem by invoking timer:sleep/1 and it seems to solve my problem. However sleep time and `filesync_repeat_interval` for `logger_disk_log_h` needs to be in agreement which is explicit coupling that i don’t like. Is there any facility like `flush` that would force logger to output what it has at the moment so that use of sleep could be eliminated?

note: i’m currently not starting my code as `application` behavior.

---

<div class="post-metadata">

**Author:** ![kuna.prime](https://erlangforums.com/letter_avatar_proxy/v4/letter/k/b77776/32.png) [@kuna.prime](https://erlangforums.com/u/kuna.prime)\
**Post date:** [June 6, 2023, 3:12pm UTC](https://erlangforums.com/t/something-like-flush-function-for-logger/2664/2 "2023-06-06T15:12:20Z")

</div>

i have missed `logger_disk_log_h:filesync/1` which also works and removes timer need. However more general `logger:sync/0-1` would be also nice.

---

<div class="post-metadata">

**Author:** ![mikpe](https://erlangforums.com/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@mikpe](https://erlangforums.com/u/mikpe)\
**Post date:** [June 6, 2023, 5:33pm UTC](https://erlangforums.com/t/something-like-flush-function-for-logger/2664/3 "2023-06-06T17:33:30Z")

</div>

AFAIK you’ll need either for upstream to add a `sync` or `flush` to the API, or you need to break the abstractions and call `logger_olp:info(Handle)` where `Handle` is the registered name or Pid of your handler. (That’s assuming you’re using one of the OTP standard handlers.)

I agree that having this as an official part of the API would be desirable.
