# Any way to keep printing out the info/error in log using internal logging?

**URL:** <https://discourse.julialang.org/t/any-way-to-keep-printing-out-the-info-error-in-log-using-internal-logging/6958>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 8, 2017, 3:29pm UTC](https://discourse.julialang.org/t/any-way-to-keep-printing-out-the-info-error-in-log-using-internal-logging/6958 "2017-11-08T15:29:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwu/32/3775_2.png) [@jwu](https://discourse.julialang.org/u/jwu)\
**Post date:** [November 8, 2017, 3:29pm UTC](https://discourse.julialang.org/t/any-way-to-keep-printing-out-the-info-error-in-log-using-internal-logging/6958/1 "2017-11-08T15:29:58Z")

</div>

In julia 0.6 Base, we have logging function to log. But I did not find any way to keep printing out the information while logging.

```julia
julia> logging(open("/tmp/testlog.txt","w"))                 
                                                             
julia> info("test info")                                     
                                                             
julia> error("test error")                                   

```

---

<div class="post-metadata">

**Author:** ![sunoru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sunoru/32/461_2.png) [@sunoru](https://discourse.julialang.org/u/sunoru)\
**Post date:** [November 9, 2017, 3:28am UTC](https://discourse.julialang.org/t/any-way-to-keep-printing-out-the-info-error-in-log-using-internal-logging/6958/2 "2017-11-09T03:28:07Z")

</div>

Do you mean that while logging to a file you want to print the logs to your screen as well?

You could try a `Tee` struct:

```julia
import Base.print
struct Tee <: IO
    ios :: Vector{IO}
end
print(tee::Tee, x::AbstractString) = for io in tee.ios print(io, x) end
print(tee::Tee, xs...) = for io in tee.ios print(io, xs...) end

```

And use `Tee`:

```julia
f = open("a.txt", "w")
tee = Tee([f1, STDERR])
logging(tee)
info("info")
warn("warn")

```

But note that `error` is a special function that throws an error instead of just doing some logging, so this simple implementation works well with just `info` and `warn`.

Or you can use the unix `tee` command like this (and no need for `logging(f)`):

```bash
$ julia --color=yes testlog.jl 2> >(tee testlog.txt)

```
