It appears to be a "by design" behavior of the diagnostic setting. I would suggest you to replace the single quotes with double quotes using the golang
https://www.geeksforgeeks.org/strings-replace-function-in-golang-with-examples/
Invalid JSON logs produced for function apps.
I have a function app on a consumption plan with custom runtime written in Go. The app writes a valid JSON to a console output.
I am using diagnostic settings to send Function Application Logs to a Log Analytics workspace and a partner solution (elastic cloud).
The problem is that Azure replace all double quotes to single quotes on all logs generated by the app before it is send to log analytics or partner solution. This makes it unusable since it is not a valid JSON.
{
"time": "2022-09-10T10:27:45Z",
"resourceId": "/SUBSCRIPTIONS/xxx/RESOURCEGROUPS/xxx/PROVIDERS/MICROSOFT.WEB/SITES/xxx",
"category": "FunctionAppLogs",
"operationName": "Microsoft.Web/sites/functions/log",
"level": "Error",
"location": "West Europe",
"properties": {'appName':'xxx','roleInstance':'xxx','message':'{\'level\':\'info\',\'time\':\'2022-09-10T10:27:45.818077054Z\',\'message\':\'init config\'}','category':'Host.Function.Console','hostVersion':'4.10.4.4','hostInstanceId':'xxx','level':'Error','levelId':4,'processId':60}
}
As you can see everything in properties has single quotes and what my app generates is in the message field.
Same in the log analytics workspace.
Note: I am not using Application Insights.
-
MughundhanRaveendran-MSFT 12,481 Reputation points
2022-09-16T08:45:32.96+00:00