0

I have an Express server which is running on IIS via iisnode. At the starting point, I have included logging to file to indicate whether MongoDB has been successfully booted.

It works without issue when I try this on my development PC (without IIS), but it seems file is not written or created when you start Express using IIS, at least not until a request is made, then the log file appears.

Is there a workaround for this?Thanks.

YYTan
  • 471
  • 1
  • 5
  • 21

1 Answers1

0

It seems the only way to make sure the file is written to a custom log file (eg. using Winston) when first starting Express (through IIS and iisnode), is by writing to stdout. I thought this would only affect iisnode logging of stdout or stderr, but it seems to be affecting the logging inside my .js files.

Hence, if you need to see the log (eg. connection to database) when your Express is starting, without making any http request (mine is acting as RESTful API server), just write to stdout,

process.stdout.write('Test');
YYTan
  • 471
  • 1
  • 5
  • 21