2

I am unable to get logging to work for a node application I am deploying to Windows Azure. I am overriding the web.config with the iisnode.yml file option.

Here's the yml file contents:

node_env: development
nodeProcessCountPerApplication: 1
maxConcurrentRequestsPerProcess: 1024
maxNamedPipeConnectionRetry: 24
namedPipeConnectionRetryDelay: 250
maxNamedPipeConnectionPoolSize: 512
maxNamedPipePooledConnectionAge: 30000
asyncCompletionThreadCount: 0
initialRequestBufferSize: 4096
maxRequestBufferSize: 65536
watchedFiles: *.js;iisnode.yml
uncFileChangesPollingInterval: 5000
gracefulShutdownTimeout: 60000
loggingEnabled: true
logDirectory: iisnode
debuggingEnabled: true
debuggerPortRange: 5058-6058
debuggerPathSegment: debug
maxLogFileSizeInKB: 128
maxTotalLogFileSizeInKB: 1024
maxLogFiles: 20
devErrorsEnabled: true
flushResponse: false
enableXFF: false

Here's the contents of the web.config file that's being overriden:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="false" />
        <iisnode configOverrides="iisnode.yml" debuggingEnabled="true" loggingEnabled="true" logDirectory="iisnode" devErrorsEnabled="true" nodeProcessCommandLine="&quot;%programfiles(x86)%\nodejs\node.exe&quot;"  />
        <handlers>
            <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
        </handlers>
        <rewrite>
            <rules>
                <clear />
                <rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="server\.js.+" negate="true" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="server.js" />
                </rule>
                <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="iisnode"/>
                </rule>
                <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="^server.js\/debug[\/]?" />
                </rule>
                <rule name="StaticContent">
                    <action type="Rewrite" url="public{{REQUEST_URI}}"/>
                </rule>
                <rule name="DynamicContent">
                    <conditions>
                        <add input="{{REQUEST_FILENAME}}" matchType="IsFile" negate="True"/>
                    </conditions>
                    <action type="Rewrite" url="server.js"/>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

I'm pretty sure I have enabled every logging option I can in both, but neither seems to be picked up by Azure during deployment and when I access the typical logging location, http://mysite.com/iisnode/index.html or http://mysite.com/iisnode/ I receive a 404 error.

Any help or ideas would be appreciated.

el doug
  • 21
  • 2

1 Answers1

5

If you are using express add this under your static folder location

app.use(express.static(__dirname + '/../iisnode'));

Or define your own log routes like below.. here you can get fancy and only show errors etc.

//logging routes
var fs = require('fs');
app.get('/iisnode', function(req, res){
  var _index = fs.readFileSync('./iisnode/index.html', 'utf8');
  var index = _index.replace("logCell.innerHTML = '<a href=\"' + logFile.file + '\">log</a>';", "logCell.innerHTML = '<a href=\"/iisnode/' + logFile.file + '\">log</a>';");
  res.send(index);
});

app.get('/iisnode/:log', function(req, res){
  var _log = fs.readFileSync('./iisnode/' + req.route.params['log'], 'utf8');
  res.contentType('text/plain');
  res.send(_log);
});

You can replace the app.get with whatever routing solution you are using.

Remember to remove before launching the app in production.

RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262