# TeeLogger and stdout/stderr redirection

**URL:** https://discourse.julialang.org/t/teelogger-and-stdout-stderr-redirection/87641
**Category:** General Usage
**Tags:** question, logging, io
**Created:** [September 22, 2022, 12:59pm UTC](https://discourse.julialang.org/t/teelogger-and-stdout-stderr-redirection/87641 "2022-09-22T12:59:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dapz](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@dapz](https://discourse.julialang.org/u/dapz)
#### Post date: [September 22, 2022, 12:59pm UTC](https://discourse.julialang.org/t/teelogger-and-stdout-stderr-redirection/87641/1 "2022-09-22T12:59:17Z")

</div>

Hi, I would like to run some code and get all the outputs: (1) either on the console or (2) redirected to a file or (3) both at the same time. I have been using Logging utilities and LoggingExtras to define a TeeLogger to deal with (3), which works well to handle the log messages… the problem is that I would like to do the same with all outputs, including e.g. the output of the `println` statements. I tried to use `redirect_stdout` and the variant for stderr (to get these statement also redirected), but if I do so it then also redirects the log messages to the file, so I cannot achieve (3) anymore… Any thought on what is the correct way to do this? Is there a way to just send the Log messages to stdout and then send stdout to both console and a file?
