`log_history` does not contain metrics anymore
Since version 3.5.0 the `log_history` of the trainer does not contain the metrics anymore. Version 3.4.0 works...

My trainer uses a `compute_metrics` callback. It avaluates after each epoch. At version 3.4.0 after the training I am extracting the last epoch results: `trainer.state.log_history[-1]` to log the metrics.

At version 3.5.0 the dict only contains loss and epoch number but not the computed metrics. 

I think anything was changed that broke the metric logging. I can not provide example code. Sorry...


`evaluate` calls `log` which appends the results to `log_history`. So the code is there. Without a reproducer to investigate, there is nothing we can do to help.<|||||>Here is the demo code that shows the bug: https://colab.research.google.com/drive/1dEzkDoMampL-VVrQeO924HQmHXffya0Z?usp=sharing

The last line should print all metrics and does that with version 3.4.0 but not with 3.5.0

Output of 3.4.0 (which is correct):
```
{'eval_loss': 0.5401068925857544, 'eval_f1_OTHER': 0.8642232403165347, 'eval_f1_OFFENSE': 0.6730190571715146, 'eval_recall_OTHER': 0.9230427046263345, 'eval_recall_OFFENSE': 0.5834782608695652, 'eval_acc': 0.8081224249558564, 'eval_bac': 0.7532604827479499, 'eval_mcc': 0.5547059570919702, 'eval_f1_macro': 0.7686211487440247, 'epoch': 2.0, 'total_flos': 668448673730400, 'step': 628}
```


Bug in 3.5.0:
```
{'total_flos': 668448673730400, 'epoch': 2.0, 'step': 628}
```<|||||>Ah it's not a bug. In 3.5.0 there is one final log entry for the total_flos (instead of logging them during training as it's only useful at the end). So you can still access all your metrics but with the second-to-last entry (`trainer.state.log_history[-2]`).<|||||>Hi @sgugger ok thanks for the info.
It might be no bug but honestly. This logging "API" is very fragile. What happens if I do a `[-2]` now and in the next release the final log entry for the total_flos is moved to an other list. Then I am getting the result of the 2nd last epoch instead of the last one.

IMO this logging "API" needs a clean and better redesign. Or do I just use it in a wrong way?<|||||>There are plenty of things that could log more info: a callback, some other tweak in training performed at the end. IMO you shouldn't rely on a hard-coded index but loop from the end of the `log_history` until you find a dict with the metric values.<|||||>Ok. Closing this.