Can the DEBUG information of node-red be logged?

Can the DEBUG information of node-red be logged or stored in a file? I know that the file node can be used to store the file, but the file can only store the information of msg.payload. I want to store or record the entire msg information like DEBUG. log.

look at the contrib node node-red-contrib-flogger - it was designed for that purpose.

Yes it can, you can use a custom logger for that, see the docs for settings.js