私は定型的なコードを使用しています意味.io次のコマンドでサーバーを起動します:
node server.js
Express アプリケーションにログインするにはstdout
どうすればよいですか?stderr
これが私のファイルですserver.js
:
'use strict';
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
passport = require('passport'),
logger = require('mean-logger');
/**
* Main application entry file.
* Please note that the order of loading is important.
*/
// Initializing system variables
var config = require('./server/config/config');
var db = mongoose.connect(config.db);
// Bootstrap Models, Dependencies, Routes and the app as an express app
var app = require('./server/config/system/bootstrap')(passport, db);
// Start the app by listening on <port>, optional hostname
app.listen(config.port, config.hostname);
console.log('Mean app started on port ' + config.port + ' (' + process.env.NODE_ENV + ')');
// Initializing logger
logger.init(app, passport, mongoose);
// Expose app
exports = module.exports = app;
ベストアンサー1
これはどうですか?
console.log("I will goto the STDOUT");
console.error("I will goto the STDERR");
注記:これら両方の関数は、入力に新しい行を自動的に追加します。
入力に改行を追加したくない場合は、次のようにします。
process.stdout.write("I will goto the STDOUT")
process.stderr.write("I will goto the STDERR")
process.stdout
とはどちらもprocess.stderr
ストリームなので、ストリームをパイプすることもできます。ストリームに関する Node.js ドキュメント詳細については。