Hello @avatar_ang and welcome to STcommunity!
can you explain how are you trying to print your messages in serial monitor?
in the STM32F407G-DISC1 ,the ST-Link embedded in the F407 discovery is not wired to a target MCU UART, so it has no virtual COMPORT capability.(the physical connection is missing.) you will need to add physical link wires to the Discovery board or connect to a separate USB-to-UART adaptor.
Maybe this is your issue.

If this isn't your issue , please provide more informations
BR
Gyessine
In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.