title: Save the output of xgb.train of XGBoost as a log file with python logging
body: <p>I tried to save the output of <code>xgb.train</code> of XGBoost as a log file by <code>logging</code>, but I could not record the output. How can I record it? I tried to refer to the existing Stackoverflow question but it was impossible. I would like you to show it with a concrete sample.</p>
  
  <pre class="lang-python prettyprint-override"><code>import sys
  import logging
  
  # ---------------------------------------------- #
  # Some logging settings
  # ---------------------------------------------- #
  
  import xgboost as xgb
  
  import numpy as np
  from sklearn.model_selection import KFold
  from sklearn.datasets import load_digits
  
  rng = np.random.RandomState(31337)
  
  print("Zeros and Ones from the Digits dataset: binary classification")
  digits = load_digits(2)
  y = digits['target']
  X = digits['data']
  kf = KFold(n_splits=2, shuffle=True, random_state=rng)
  for train_index, test_index in kf.split(X):
  
      param = {'max_depth':2, 'eta':0.3, 'silent':1, 'objective':'binary:logistic' }
  
      dtrain = xgb.DMatrix(X[train_index], y[train_index])
      dtest = xgb.DMatrix(X[test_index], y[test_index])
  
      # specify validations set to watch performance
      watchlist  = [(dtest,'eval'), (dtrain,'train')]
      num_round = 2
      bst = xgb.train(param, dtrain, num_round, watchlist)
  
  # I want to record this output.
  # Zeros and Ones from the Digits dataset: binary classification
  # [0]   eval-error:0.011111 train-error:0.011111
  # [1]   eval-error:0.011111 train-error:0.005556
  # [0]   eval-error:0.016667 train-error:0.005556
  # [1]   eval-error:0.005556 train-error:0
  </code></pre>