# Capturing stdout/stderr from Pkg.test

**URL:** <https://discourse.julialang.org/t/capturing-stdout-stderr-from-pkg-test/44307>\
**Category:** General Usage\
**Tags:** pkg\
**Created:** [August 5, 2020, 5:01am UTC](https://discourse.julialang.org/t/capturing-stdout-stderr-from-pkg-test/44307 "2020-08-05T05:01:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![felipenoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/felipenoris/32/553_2.png) [@felipenoris](https://discourse.julialang.org/u/felipenoris)\
**Post date:** [August 5, 2020, 5:01am UTC](https://discourse.julialang.org/t/capturing-stdout-stderr-from-pkg-test/44307/1 "2020-08-05T05:01:25Z")

</div>

Is it possible to call `Pkg.test` and make it capture all the output from the test process?

I’m trying something like the code below, but the tests run in a sandbox so I guess that’s why I’m unable to capture the output.

```julia
function fetch_logs(io)
    buff = Vector{UInt8}(undef, bytesavailable(io))
    readbytes!(io, buff)
    return String(buff)
end

rd, wr = redirect_stdout()
Pkg.test()
write(log_file_io, fetch_logs(rd))

```

---

<div class="post-metadata">

**Author:** ![felipenoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/felipenoris/32/553_2.png) [@felipenoris](https://discourse.julialang.org/u/felipenoris)\
**Post date:** [August 5, 2020, 5:26am UTC](https://discourse.julialang.org/t/capturing-stdout-stderr-from-pkg-test/44307/2 "2020-08-05T05:26:09Z")

</div>

I guess the only way to do this currently is to do something like:

```julia
run(pipeline(`julia --project=$pkgdir -e 'import Pkg; Pkg.test(test_args = ["test-args"])'`, stdout="out.txt", stderr="errs.txt"))

```
