# Distributed and logging

**URL:** <https://discourse.julialang.org/t/distributed-and-logging/66503>\
**Category:** General Usage\
**Tags:** distributed, logging\
**Created:** [August 16, 2021, 5:19pm UTC](https://discourse.julialang.org/t/distributed-and-logging/66503 "2021-08-16T17:19:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![torgo](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@torgo](https://discourse.julialang.org/u/torgo)\
**Post date:** [August 16, 2021, 5:19pm UTC](https://discourse.julialang.org/t/distributed-and-logging/66503/1 "2021-08-16T17:19:55Z")

</div>

I am trying to add a timestamp to a logger using `LoggingExtras`. I would like that timestamp to be propagated across workers, but I haven’t been able to figure out how.

Here’s my MWE:

```julia
module TestParLogging

    using Distributed
    using Dates, LoggingExtras

    function foo()
        timestamp_logger(logger) = TransformerLogger(logger) do log
            merge(log, (; message =
                        "$(Dates.format(now(), "mm-dd HH:MM:SS")) $(log.message)"))
        end
        TeeLogger(
            ConsoleLogger(stdout) |> timestamp_logger
        ) |> global_logger

        pmap(1:4) do i
            @info "Worker $(myid()) is starting $i"
            sleep(5)
        end
    end
    export foo

end

```

When I run this with a single worker I see the logging time stamps, as expected:

```julia
[ Info: 08-16 12:14:07 Worker 1 is starting 1
[ Info: 08-16 12:14:12 Worker 1 is starting 2
[ Info: 08-16 12:14:17 Worker 1 is starting 3
[ Info: 08-16 12:14:22 Worker 1 is starting 4

```

Then I try to run in parallel by loading julia `julia -p 4`, then these commands:

```julia
using Distributed
@everywhere using Pkg
@everywhere Pkg.activate(".")
@everywhere Pkg.instantiate()
@everywhere using TestParLogging
foo()

```

The parallelization works, but the time stamps are not shown:

```julia
[ Info: Worker 4 is starting 3
[ Info: Worker 5 is starting 4
[ Info: Worker 3 is starting 2
[ Info: Worker 2 is starting 1

```

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![jorikcaljouw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jorikcaljouw/32/217505_2.png) [@jorikcaljouw](https://discourse.julialang.org/u/jorikcaljouw)\
**Post date:** [June 30, 2025, 9:51am UTC](https://discourse.julialang.org/t/distributed-and-logging/66503/2 "2025-06-30T09:51:53Z")

</div>

This is a very late reply, but I was looking for some Distributed logging and found this post. I think the issue is related to the fact that `foo()` itself does not run on the workers, only the `@info` / `sleep`, so the logging is not updated on the workers (remember these are separate julia processes). Instead you may want to put the code for setting up the loggers in a separate function and call that also with `@everywhere` before calling `foo()`
