# Consistent way to suppress solver output

**URL:** https://discourse.julialang.org/t/consistent-way-to-suppress-solver-output/20437
**Category:** Optimization (Mathematical)
**Created:** [February 4, 2019, 4:55pm UTC](https://discourse.julialang.org/t/consistent-way-to-suppress-solver-output/20437 "2019-02-04T16:55:20Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![MAJegh](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@MAJegh](https://discourse.julialang.org/u/MAJegh)
#### Post date: [December 26, 2021, 9:17pm UTC](https://discourse.julialang.org/t/consistent-way-to-suppress-solver-output/20437/9 "2021-12-26T21:17:56Z")

</div>

Had some trouble with this where output was still printed.  
It was due to the C level output not being flushed before the stdout gets restored.  
So might be helpful to call :

> Base.Libc.flush\_cstdio()

Can use the following to print to a file as well :

```julia
open("/dev/null", "w") do f
    redirect_stdout(f) do
    # redirect_stdio(stdout=f,stderr=f) do
        optimize!(model)
        Base.Libc.flush_cstdio()
    end
end

```

---

_[View the full topic](https://discourse.julialang.org/t/consistent-way-to-suppress-solver-output/20437)._
