Logging? getting logs data?

I’m currently trying to implements logs.
My first option was to actually use an external file for logging, but for some reason It won’t save the file when it should.

for example:

I do see the ‘test’ in the terminal, but the file is not being created.
And I didn’t find anything to view the logs in anotherway.

I need to see the logs outside of the terminal somehow, is there a way to do it?

Thanks a lot!