The answer is, it depends.
It depends on who is supposed to consume the string and what the conventions within the team are.
If the string is a message to the end-user, then it it likely that the string needs to be translated. The actual message for the end-user will live in a translation file and in the code you will only have a key for locating that message. The format of that key can range from a numeric identifier, a textual identifier or even a full sentence. Where those keys are defined depends on local conventions and ranges from a central file (most common with numeric keys) to the point where you need the text (most common with full sentence keys).
If the string is a log message that is intended for the developer/maintainers of the software, then it is most common to have that string hard-coded in the logging statement.
If the string is used as a identifier within the software, then it is common to create a constant for it at the appropriate scope, so that if you need to change the content of the string, you only have to do it at one spot and you can't accidentally forget to update it in a location where it is used.