Transformers logging setLevel method seems not to work
Author: AndreaSottana
Pull request: no

### System Info

- `transformers` version: 4.21.3
- Platform: Linux-5.15.0-33-generic-x86_64-with-glibc2.35
- Python version: 3.10.4
- Huggingface_hub version: 0.9.1
- PyTorch version (GPU?): 1.11.0+cu113 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: Yes

### Who can help?

@LysandreJik @sgugger 

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

I am subclassing the `Trainer` object because I want to inject some custom features in the `_inner_training_loop` method. What I noticed is that once I do that, the `logger.info` printouts, which when using the standard `Trainer` are printed to the console, are now no longer printed. Even If I try to explicitly force the logger level, this seems not to work. To reproduce the behaviour, run the script below

```python3
from transformers.utils import logging
logger = logging.get_logger(__name__)
logger.setLevel("INFO")
logger.info("Hello World")
```

### Expected behavior

I would expect `Hello World` to be printed to the console, but it is not.
Why is this the case? How can I set it such that it also prints out INFO level logs?

Comments:
I'll try

I am a beginner and unfortunately could not find an example with your issue. I know the logging library and probably could help, but I need to reproduce the example

Any thoughts @LysandreJik @sgugger ?

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

Hey @AndreaSottana, sorry to have missed this.

The `logging` module for `transformers` acts on the code within `transformers` itself (this is how the `logging` library works), not on user code. 

However, by doing the following line:
```py
logger = logging.get_logger(__name__)
```
The logger created will not depend from `transformers` but from the module you're currently running. It will, therefore, not be impacted by the methods which affect `transformers`' logging module.

This is not the cleanest workaround, but you could get what you want by specifying that this logger instance should behave as a `transformers` module with something like the following:
```py
from transformers.utils import logging
logger = logging.get_logger('transformers.custom.' + __name__)
logger.setLevel("INFO")
logger.info("Hello World")
```

This will trick it into understanding that `logger` is the logger for a module that lives within `transformers.custom`. This should print out
```
Hello World
```
just fine.