Logs disabled on console

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

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

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

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; }

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

$ ./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

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

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

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