-
Notifications
You must be signed in to change notification settings - Fork 3
Cookbook: Configure Logging
Rupert's logger has 9 levels. From most to least promiscuous, they are 'silly'
, 'data'
, 'debug'
, 'verbose'
, 'http'
, 'info'
, 'warn'
, 'error'
, and 'silent'
. Default is 'http'
.
In the Rupert config object, the log
object has a property, level
. It should be a string, matching one of the above.
To change the log level for a single run, set the environment variable LOG_LEVEL
to a string value of one of the above.
Rupert logs http requests at the 'http'
level using morgan. Change the output format using log.level
in the Rupert config object, or for a single run with the LOG_FORMAT
environment variable. Default value is 'tiny'
, and valid are any morgan formats. At this time, it is not possible to define new morgan tokens for Rupert.
The Rupert logger is an excellent tool to capture information necessary for devops and ongoing performance and analytics. The Rupert logger is less suitable to capturing short-term debugging information. Instead, use the debug utility.
var debug = require('debug')('myapp');
var error = require('debug')('myapp:ERROR');
function MyDataManager(options){
debug('Loading data', options);
if (!options.expectedRequiredParam){
error('Options did not have expected parameter');
}
}
To see the specific logs, set the DEBUG
variable in the environment. DEBUG=myapp* npm start
will run the Rupert application, and include any debugging information matching the myapp
key.
Rupert and many of its libraries use debug
to provide additional information in development situations.
Includes some rupert specific information, including loaded configuration settings.
Includes detailed information on when files are modified, compiled, and ready to serve.
Includes information on middleware and routes supplied to express.
A tremendous wealth of information on when socket.io connections are created, used, and destroyed.