# Logs disabled on console

**URL:** <https://root-forum.cern.ch/t/logs-disabled-on-console/19428>\
**Category:** ROOT\
**Created:** [June 27, 2015, 7:46am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428 "2015-06-27T07:46:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pioflor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/6a8cbe/32.png) [@pioflor](https://root-forum.cern.ch/u/pioflor)\
**Post date:** [June 27, 2015, 7:46am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428/1 "2015-06-27T07:46:27Z")

</div>

I do not know how to express it. How to disable the logs displayed on the console during the program operation.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 27, 2015, 8:02am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428/2 "2015-06-27T08:02:41Z")

</div>

On Unix / MacOS, if you use sh/bash, try:  
MYProgram \> /dev/null 2\>&1  
if you use csh/tcsh, try:  
MyProgram \>& /dev/null

---

<div class="post-metadata">

**Author:** ![pioflor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/6a8cbe/32.png) [@pioflor](https://root-forum.cern.ch/u/pioflor)\
**Post date:** [June 27, 2015, 8:18am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428/3 "2015-06-27T08:18:15Z")

</div>

Without user intervention. Simply, the program does not display anything on the console.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 27, 2015, 8:43am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428/4 "2015-06-27T08:43:18Z")

</div>

In your c++ code (just in the beginning of your “main”) you can redirect “stdout”, “stderr”, “std::cout”, “std::cerr” to “/dev/null” (or to any file, if you like).  
Actually I think it should be sufficient to simply “close” all these streams: `#include <cstdio>
#include <iostream>
int main(void) {
  fprintf(stdout, "stdout ... BEFORE\n");
  fprintf(stderr, "stderr ... BEFORE\n");
  std::cout << "std::cout ... BEFORE" << std::endl;
  std::cerr << "std::cerr ... BEFORE" << std::endl;
  fclose(stdout); // close "stdout" and "std::cout"
  fclose(stderr); // close "stderr" and "std::cerr"
  fprintf(stdout, "stdout ... AFTER\n");
  fprintf(stderr, "stderr ... AFTER\n");
  std::cout << "std::cout ... AFTER" << std::endl;
  std::cerr << "std::cerr ... AFTER" << std::endl;
  return 0;
}`

---

<div class="post-metadata">

**Author:** ![pioflor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/6a8cbe/32.png) [@pioflor](https://root-forum.cern.ch/u/pioflor)\
**Post date:** [June 27, 2015, 9:02am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428/5 "2015-06-27T09:02:36Z")

</div>

I want to use cout, but I want to disable only those automatically generated by ROOT and Pythia.  
For example:

```auto
$ ./cut_test22 
Warning in <TROOT::Append>: Replacing existing TH1: #phi (Potential memory leak).
Warning in <TROOT::Append>: Replacing existing TH1: #phi (Potential memory leak).

 *------------------------------------------------------------------------------------* 
 | | 
 | *------------------------------------------------------------------------------* | 
 | | | | 
 | | | | 
 | | PPP Y Y TTTTT H H III A Welcome to the Lund Monte Carlo! | |                                 
 | | P P Y Y T H H I A A This is PYTHIA version 8.180 | |                                 
 | | PPP Y T HHHHH I AAAAA Last date of change: 22 Sep 2013 | |                                 
 | | P Y T H H I A A | |                                 
 | | P Y T H H III A A Now is 27 Jun 2015 at 11:02:02 | |                                 
 | | | |                                 
 | | Torbjorn Sjostrand; Department of Astronomy and Theoretical Physics, | |                                 
 | | Lund University, Solvegatan 14A, SE-223 62 Lund, Sweden; | | 
 | | phone: + 46 - 46 - 222 48 16; e-mail: torbjorn@thep.lu.se | | 
 | | Jesper Roy Christiansen; Department of Astronomy and Theoretical Physics, | | 
 | | Lund University, Solvegatan 14A, SE-223 62 Lund, Sweden; | | 
 | | e-mail: Jesper.Roy.Christiansen@thep.lu.se | | 
 | | Nishita Desai; Department of Physics and Astronomy, University College | | 
 | | London, Gower Street, London, WC1E 6BT, United Kingdom; | | 
 | | e-mail: Nishita.Desai@cern.ch | | 
 | | Philip Ilten; School of Physics, Uniiversity College Dublin, | | 
 | | Belfield, Dublin 4, Ireland; | | 
 | | e-mail: philten@cern.ch | | 
 | | Stephen Mrenna; Computing Division, Simulations Group, | | 
 | | Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA; | | 
 | | phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov | | 
 | | Stefan Prestel; Theory Group, DESY, | | 
 | | Notkestrasse 85, D-22607 Hamburg, Germany; | | 
 | | phone: + 49 - 40 - 8998-4250; e-mail: stefan.prestel@thep.lu.se | | 
 | | Peter Skands; Theoretical Physics, CERN, CH-1211 Geneva 23, Switzerland; | | 
 | | phone: + 41 - 22 - 767 2447; e-mail: peter.skands@cern.ch | | 
 | | Stefan Ask; former author; e-mail: ask.stefan@gmail.com | | 
 | | Richard Corke; former author; e-mail: r.corke@errno.net | | 
 | | | | 
 | | The main program reference is the 'Brief Introduction to PYTHIA 8.1', | | 
 | | T. Sjostrand, S. Mrenna and P. Skands, Comput. Phys. Comm. 178 (2008) 85 | | 
 | | [arXiv:0710.3820] | | 
 | | | | 
 | | The main physics reference is the 'PYTHIA 6.4 Physics and Manual', | | 
 | | T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026 [hep-ph/0603175]. | | 
 | | | | 
 | | An archive of program versions and documentation is found on the web: | | 
 | | http://www.thep.lu.se/~torbjorn/Pythia.html | | 
 | | | | 
 | | This program is released under the GNU General Public Licence version 2. | | 
 | | Please respect the MCnet Guidelines for Event Generator Authors and Users. | | 
 | | | | 
 | | Disclaimer: this program comes without any guarantees. | | 
 | | Beware of errors and use common sense when interpreting results. | | 
 | | | | 
 | | Copyright (C) 2013 Torbjorn Sjostrand | | 
 | | | | 
 | | | | 
 | *------------------------------------------------------------------------------* | 
 | | 
 *------------------------------------------------------------------------------------* 

 PYTHIA Warning in ParticleDataEntry::initBWmass: switching off width for id = 36

```

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 27, 2015, 9:07am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428/6 "2015-06-27T09:07:50Z")

</div>

In this case, search this forum for “verbosity”, e.g.:

> [@How to decrease verbosity](https://root-forum.cern.ch/t/how-to-decrease-verbosity/14045/1):
>
> Hello everybody, I have a root script toto.C and I open it like this : root toto.C I would like to suppress this default echo Processing toto.C… and also this one Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1 Is there the way change the root verbosity ? By advance thank you Olivier

> [@How to set output verbosity level in ROOT?](https://root-forum.cern.ch/t/how-to-set-output-verbosity-level-in-root/11149/1):
>
> Dear rooters, There are several functions in TObject specifying different levels of output: Info() Warning() Error() SysError() Fatal() Is it possible to set the verbosity level so that ROOT will print messages with higher verbosity? For example, is there something like: and then Info(), Warning() will be ignored, while Error(), SysError() and Fatal() will be called. I guess ROOT has this kind of system. Is there any documentation or examples? Cheers, Jing

> [@Verbosity level](https://root-forum.cern.ch/t/verbosity-level/8590/1):
>
> hi, this is a basic question indeed: how can one suppress the warning messages about missing branches when reading a ttree? Error in TTree::SetBranchStatus: unknown branch -\> of course, as suggested in the past, one can simply comment the corresponding branch, but does ROOT implement some feature, like verbosity level, such that these error messages will be automatically suppressed? thanks.

---

<div class="post-metadata">

**Author:** ![pioflor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/6a8cbe/32.png) [@pioflor](https://root-forum.cern.ch/u/pioflor)\
**Post date:** [June 27, 2015, 9:31am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428/7 "2015-06-27T09:31:12Z")

</div>

I added in my code #include “TError.h” and gErrorIgnoreLevel = kError and the logs are written.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 27, 2015, 9:34am UTC](https://root-forum.cern.ch/t/logs-disabled-on-console/19428/8 "2015-06-27T09:34:10Z")

</div>

Note that these are ROOT-only tricks.  
For pythia8 tricks you need to search elsewhere.
