# Logging "one logbook file - one process". How?

**URL:** <https://erlangforums.com/t/logging-one-logbook-file-one-process-how/4567>\
**Category:** Questions / Help\
**Tags:** erlang-logger, erlang-otp\
**Created:** [March 5, 2025, 5:12am UTC](https://erlangforums.com/t/logging-one-logbook-file-one-process-how/4567 "2025-03-05T05:12:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexandr](https://erlangforums.com/user_avatar/erlangforums.com/alexandr/32/2162_2.png) [@alexandr](https://erlangforums.com/u/alexandr)\
**Post date:** [March 5, 2025, 5:12am UTC](https://erlangforums.com/t/logging-one-logbook-file-one-process-how/4567/1 "2025-03-05T05:12:50Z")

</div>

Hello all!

In application on server have some active processes that is generating some events. Every process has own logbook. For this functionality written own solution based on keeping files opened and handling it with OTP gen\_server. All is working.

But trying to find any erlang-in-box solution. Is there any?  
Tried to find something in this manuals but still not clear of how to make logging per process:

- [logger — kernel v10.2.2](https://www.erlang.org/doc/apps/kernel/logger.html)
- [Logging — kernel v10.2.2](https://www.erlang.org/doc/apps/kernel/logger_chapter.html)

The functionality that is required by application:  
– rotating logbook by time or file size  
– starting at time of process start and stopping when process down  
– archiving logs if needed

---

<div class="post-metadata">

**Author:** ![vances](https://erlangforums.com/user_avatar/erlangforums.com/vances/32/710_2.png) [@vances](https://erlangforums.com/u/vances)\
**Post date:** [March 5, 2025, 7:16am UTC](https://erlangforums.com/t/logging-one-logbook-file-one-process-how/4567/2 "2025-03-05T07:16:31Z")

</div>

The [`disk_log`](https://www.erlang.org/doc/apps/kernel/disk_log.html) module provides an API for managing logs of sequential terms written to disk. It supports `wrap` logs which allow you to choose how many files and of what maximim size. These log files may be efficient `internal` format or `external` (i.e. plain text) format.

In your use case you would [`open/1`](https://www.erlang.org/doc/apps/kernel/disk_log.html#open/1) a log when your procesess started and then periodically [`log/2`](https://www.erlang.org/doc/apps/kernel/disk_log.html#log/2) (`internal`) or [`blog/2`](https://www.erlang.org/doc/apps/kernel/disk_log.html#blog/2) (`external`) to the log.

---

<div class="post-metadata">

**Author:** ![alexandr](https://erlangforums.com/user_avatar/erlangforums.com/alexandr/32/2162_2.png) [@alexandr](https://erlangforums.com/u/alexandr)\
**Post date:** [March 6, 2025, 8:23am UTC](https://erlangforums.com/t/logging-one-logbook-file-one-process-how/4567/3 "2025-03-06T08:23:33Z")

</div>

> [@vances](#):
>
> log/2

Thx. Will try to use it and reply on result in this thread soon.

---

<div class="post-metadata">

**Author:** ![alexandr](https://erlangforums.com/user_avatar/erlangforums.com/alexandr/32/2162_2.png) [@alexandr](https://erlangforums.com/u/alexandr)\
**Post date:** [March 10, 2025, 6:05am UTC](https://erlangforums.com/t/logging-one-logbook-file-one-process-how/4567/4 "2025-03-10T06:05:25Z")

</div>

Found troubles with using disk\_log. If one of started disk\_logs crashed, all other opened disk\_logs crashing on this node. All of them working together. Do you know of any ability to prevent crashing all logs if one crashed?

---

<div class="post-metadata">

**Author:** ![vances](https://erlangforums.com/user_avatar/erlangforums.com/vances/32/710_2.png) [@vances](https://erlangforums.com/u/vances)\
**Post date:** [March 10, 2025, 7:18am UTC](https://erlangforums.com/t/logging-one-logbook-file-one-process-how/4567/5 "2025-03-10T07:18:01Z")

</div>

A process is created to handle a `disk_log` when it is (first) opened and the process which does so will be an owner. If an owner terminates the `disk_log` is closed. You may open a `disk_log` as an anonymous user not owner, with the `linkto` option.
