# Custom logger handlers overload protection

**URL:** <https://erlangforums.com/t/custom-logger-handlers-overload-protection/2763>\
**Category:** Questions / Help\
**Tags:** erlang-logger\
**Created:** [July 26, 2023, 7:03am UTC](https://erlangforums.com/t/custom-logger-handlers-overload-protection/2763 "2023-07-26T07:03:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlangMax](https://erlangforums.com/letter_avatar_proxy/v4/letter/e/b38774/32.png) [@erlangMax](https://erlangforums.com/u/erlangMax)\
**Post date:** [July 26, 2023, 7:03am UTC](https://erlangforums.com/t/custom-logger-handlers-overload-protection/2763/1 "2023-07-26T07:03:58Z")

</div>

I developed a logger handler that redirects JSON formatted logs to a remote server on the internet.  
In the logger user’s guide there is mention of overload protection for the default logger handlers [Erlang -- Logging](https://www.erlang.org/doc/apps/kernel/logger_chapter.html#protecting-the-handler-from-overload) .  
Apparently this is implemented in the `logger_olp`module that is used by the `logger_h_common` callbacks. I read the code in `logger_disk_log_h` and the OLP management for the standard OTP handlers is provided by `logger_h_common:log/2` that in turn calls `logger_olp:load/2`.

I was wondering whether by starting a `logger_olp` instance and directly calling `logger_olp:load/2`from a custom handler would be enough to provide the same kind of overload protection.  
I would also provide the proper handling of stop/termination of the OLP server.

Do you think that using the undocumented OLP modules is feasible or that would be better to develop my own overload protection method?

---

<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:** [July 26, 2023, 8:37am UTC](https://erlangforums.com/t/custom-logger-handlers-overload-protection/2763/2 "2023-07-26T08:37:00Z")

</div>

If you’re implementing a custom logger handler then you’ll need custom code for its overload protection, if any. The one in OTP, `logger_olp`, is not a public API and it’s very closely integrated with OTP’s built-in logger handlers. Don’t use it.

If you’re studying `logger_olp` for inspiration, please use only very recent code due to [logger's overload protection gets slower as its message queue length grows · Issue #7417 · erlang/otp · GitHub](https://github.com/erlang/otp/issues/7417)

---

<div class="post-metadata">

**Author:** ![erlangMax](https://erlangforums.com/letter_avatar_proxy/v4/letter/e/b38774/32.png) [@erlangMax](https://erlangforums.com/u/erlangMax)\
**Post date:** [July 26, 2023, 9:41am UTC](https://erlangforums.com/t/custom-logger-handlers-overload-protection/2763/3 "2023-07-26T09:41:31Z")

</div>

Thank you for the quick answer.  
I guess I will Implement my own overload protection loosely based on the OTP one. The code I was looking at is from OTP 26, so I guess it adresses Issue #7417.
