# Suppress all ouptuts in the console when using C\_API of ipopt

**URL:** <https://discourse.julialang.org/t/suppress-all-ouptuts-in-the-console-when-using-c-api-of-ipopt/143169>\
**Category:** Optimization (Mathematical)\
**Tags:** ipopt\
**Created:** [November 24, 2026, 8:29pm UTC](https://discourse.julialang.org/t/suppress-all-ouptuts-in-the-console-when-using-c-api-of-ipopt/143169 "2026-11-24T20:29:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aitzkora](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aitzkora/32/14610_2.png) [@aitzkora](https://discourse.julialang.org/u/aitzkora)\
**Post date:** [November 24, 2026, 8:29pm UTC](https://discourse.julialang.org/t/suppress-all-ouptuts-in-the-console-when-using-c-api-of-ipopt/143169/1 "2026-11-24T20:29:47Z")

</div>

Hi,  
I want to suppress the ouptut when I’m using the C\_API of Ipopt : I set print\_level to 0 like in the following example

```julia
using Ipopt
using LinearAlgebra
using Test
# very simple example of using iptopt
# projecting a vector on the unit circle

c=[1:10;]

function f(x::Vector{Float64})
  dot(x - c, x-c)/2.
end

function g!(x::Vector{Float64}, g::Vector{Float64})
  g[1] = dot(x,x)
end

function ∇f!(x::Vector{Float64}, ∇f::Vector{Float64})
  ∇f[:] = x - c;
end 

function Jg!(x::Vector{Float64},
             rows::Vector{Int32},
             cols::Vector{Int32},
             values::Union{Nothing, Vector{Float64}})
    if values == nothing
      rows[:] = ones(Int32, n)
      cols[:] = Int32.(1:n)
    else
      values[:] = 2 .* x
    end
end

function H!(x::Vector{Float64},
            rows::Vector{Int32},
            cols::Vector{Int32},
            obj_factor::Float64,
            λ::Vector{Float64},
            values::Union{Nothing, Vector{Float64}})
  n = size(x,1)
  if values == nothing 
    idx=1
    for row = 1:n
      for col = 1:row
        rows[idx] = row
        cols[idx] = col
        idx += 1
      end
    end 
  else
    idx = 1
    for i=1:n
      for j=1:i
        if i==j
          values[idx] = obj_factor * 1. # diag
          values[idx] += λ[1] * 2.0
        else 
          values[idx] = 0.0   
        end 
        idx+=1
      end
    end
  end
end
n = size(c, 1)
xₗ = -10 * ones(n)
xᵤ = 10 * ones(n)
m = 1
gₗ = [1.0]
gᵤ = [1.0]
prob = Ipopt.CreateIpoptProblem(
      n, xₗ, xᵤ, m,gₗ, gᵤ, n, n*(n+1)÷2,
      f, g!, ∇f!, Jg!, H!)
prob.x = 3. .*ones(n)
Ipopt.AddIpoptIntOption(prob, "print_level", 0) 
solvestat = Ipopt.IpoptSolve(prob)
@test c./norm(c) ≈ prob.x atol=1e-10

```

but a using banner still remains. So it pollutes my output if I want to include the optimization in a loop with display. I would want also to get the number of iterations . Must I us a callback for that ?
