# Gurobi does not display log

**URL:** https://discourse.julialang.org/t/gurobi-does-not-display-log/114442
**Category:** Optimization (Mathematical)
**Tags:** gurobi, convex-optimization
**Created:** [May 19, 2024, 1:39am UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442 "2024-05-19T01:39:36Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![CaG21](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@CaG21](https://discourse.julialang.org/u/CaG21)
#### Post date: [May 19, 2024, 1:39am UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442/1 "2024-05-19T01:39:36Z")

</div>

I am using Convex.jl in conjuction with Gurobi in a Jupyter notebook to solve a convex programming problem. Everything works but Gurobi is not displaying its log to the console in “realtime”, but it displays everything at once only at the end of the optimization. I tried to “force” the logging (even though it should be enabled by the default options), inizializing the optimizer with  
`opt = MOI.OptimizerWithAttributes(() -> Gurobi.Optimizer(GUROBI_ENV), "DisplayInterval" => 1, "OutputFlag" => 1, "LogToConsole" => 1)`  
but it does not work.  
Is there a way to do it?

PS: I tried also with Mosek and CPLEX and in those cases everything works smoothly.

---

<div class="post-metadata">

### Author: ![mtanneau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mtanneau/32/17787_2.png) [@mtanneau](https://discourse.julialang.org/u/mtanneau)
#### Post date: [May 19, 2024, 10:06pm UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442/2 "2024-05-19T22:06:23Z")

</div>

I have also seen this behavior, specifically with Gurobi. I believe this occurs because Gurobi’s log is buffered before being displayed. I do not know how to control this, nor whether it’s possible to do so.

---

<div class="post-metadata">

### Author: ![CaG21](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@CaG21](https://discourse.julialang.org/u/CaG21)
#### Post date: [May 19, 2024, 10:14pm UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442/3 "2024-05-19T22:14:04Z")

</div>

Actually, I tried to run the same code in the REPL and it works smoothly. So it seems a problem of Gurobi and Jupyter.

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [May 19, 2024, 10:26pm UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442/4 "2024-05-19T22:26:03Z")

</div>

You could try using the Logging standard library, e.g.

> [@Suppressing location information for @info in Jupyter notebook](https://discourse.julialang.org/t/suppressing-location-information-for-info-in-jupyter-notebook/90260/2):
>
> You can get this behaviour (similar to the REPL) by calling using Logging global\_logger(ConsoleLogger()) sometime before you execute @info.

---

<div class="post-metadata">

### Author: ![CaG21](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@CaG21](https://discourse.julialang.org/u/CaG21)
#### Post date: [May 20, 2024, 1:13am UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442/5 "2024-05-20T01:13:30Z")

</div>

Thank you for this suggestion. I tried, but it does not work

---

<div class="post-metadata">

### Author: ![torressa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torressa/32/202204_2.png) [@torressa](https://discourse.julialang.org/u/torressa)
#### Post date: [May 20, 2024, 7:44am UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442/6 "2024-05-20T07:44:31Z")

</div>

How long does Gurobi take? If it’s less than a 1s then it looks like as you say. For a longer running problem it looks as expected (e.g. I tried [Convex.jl/docs/src/examples/general\_examples/robust\_approx\_fitting.jl](https://github.com/jump-dev/Convex.jl/blob/v0.15.4/docs/examples_literate/general_examples/robust_approx_fitting.jl) with `m = 2000; n = 1000;`)

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [May 20, 2024, 2:59pm UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442/7 "2024-05-20T14:59:15Z")

</div>

just to note that version of the example is for v0.16.0 of Convex.jl which is about to be released; the version for the latest existing release v0.15.4 is [here](https://github.com/jump-dev/Convex.jl/blob/v0.15.4/docs/examples_literate/general_examples/robust_approx_fitting.jl) (and in rendered form [here](https://jump.dev/Convex.jl/stable/examples/general_examples/robust_approx_fitting/)).

So if anyone tries the example and gets an error about e.g. `silent` not being accepted by `solve!`, try that v0.15.4 version of the example instead, or `] add Convex#master` to update to the not-yet-released v0.16 of Convex.jl.

---

<div class="post-metadata">

### Author: ![CaG21](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@CaG21](https://discourse.julialang.org/u/CaG21)
#### Post date: [May 20, 2024, 5:20pm UTC](https://discourse.julialang.org/t/gurobi-does-not-display-log/114442/8 "2024-05-20T17:20:47Z")

</div>

It takes way more then 1s (in fact, it requires between 2 and 3 minutes)
