Also just realised “support for builtin modules in Function Nodes” means Node builtins like fs etc.
So would need to enable this configuration instead:
NODE_FUNCTION_ALLOW_EXTERNAL: For external modules sourced from n8n/node_modules directory. External module support is disabled when env variable is not set.
I now understand that the Function Node is executing the provided JavaScript using NodeVM and also that the documentation on Logging in n8n | Docs was aimed at Developers of n8n not end users writing Expressions / Function Nodes.
I was trying to use the n8n Logger / LoggerProxy in the Function Node but I guess the cleanest way to do that would mean changing the code in the Function.node.ts
e.g.
const logger = getLogger();
LoggerProxy.init(logger);
// Define the global objects for the custom function
const sandbox = {
...
logger
};