本文整理汇总了TypeScript中log4js.connectLogger函数的典型用法代码示例。如果您正苦于以下问题:TypeScript connectLogger函数的具体用法?TypeScript connectLogger怎么用?TypeScript connectLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connectLogger函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: setup
function setup(app: express.Express) {
// View engine setup
app.set("views", path.join(__dirname, "/../views"));
app.set("view engine", "pug");
// uncomment after placing your favicon in /public
// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
// Body parser setup
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Cookie parser setup
app.use(cookieParser());
// Log4js setup
app.use(log4js.connectLogger(log4js.getLogger("http"), { level: "auto" }));
// Passport setup when using
// app.use(setupedPassport.initialize());
// app.use(setupedPassport.session());
// Static dir setup
app.use(express.static(path.join(__dirname, "/../public")));
// Rooting setup
setupRoutes(app);
app.use((req, res, next) => {
const err = new HttpErrors.NotFound();
next(err);
});
app.use((err: Error, req, res, next) => {
const error = err as HttpErrors.HttpError;
res.status(error.status || 500);
const params = {
error: (process.env.NODE_ENV !== "production") ? error : null,
message: error.message
};
if (/^\/api/.test(req.originalUrl)) {
res.send(params);
} else {
res.render("error", params);
}
});
}
开发者ID:AKIRA-MIYAKE,项目名称:Typeyard,代码行数:52,代码来源:index.ts
示例2: init
static init(config: any, app: express.Application): any {
var log4js: any = require('log4js');
log4js.configure('config/log4js_setting.json');
var logger = log4js.getLogger('app');
logger.setLevel(config.log.level); // ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF
logger.info('Logging start. ');
logger.info('Log Level:' + config.log.level);
app.use(log4js.connectLogger(logger, {
level: config.log.level
}));
return logger;
}
开发者ID:masahirompp,项目名称:chords,代码行数:14,代码来源:Logger.ts
示例3:
import * as fs from 'fs';
import * as path from 'path';
import * as log4js from 'log4js';
import * as constants from '../config/constants';
const LOG_METADATA = path.parse(constants.LOG_FILE);
if (!fs.existsSync(LOG_METADATA.dir)) {
fs.mkdirSync(LOG_METADATA.dir);
}
log4js.configure({
appenders: [
{
type: 'dateFile',
filename: constants.LOG_FILE,
category: 'main',
pattern: '-yyyy-MM-dd',
alwaysIncludePattern: true
}
],
replaceConsole: false
});
export const logger = log4js.getLogger('main');
export const loggerConnect = log4js.connectLogger(logger, { level: log4js.levels.DEBUG, format: ':method - :url - :status - :response-timems' });
开发者ID:pedrosmurf,项目名称:file-org,代码行数:26,代码来源:log4js.config.ts
示例4: express
let logger = log4js.getLogger('server-config');
export let app = express();
//configuracion express, middleware y setters
app.set(_.PORT, process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
//conecta logger con express para pintar los accesos
app.use(log4js.connectLogger(log4js.getLogger("http"), { level: 'auto' }));
app.get('/', routes.index);
app.use("/api/v1/users", userController.usersRouter);
// captura todos los errores procedentes de los middleware
app.use((err:Error, req: express.Request, res: express.Response, next: express.NextFunction)=> {
logger.error(err.message);
res.status(500);
res.send( {
error: err.message
});
});
开发者ID:migueluvieu,项目名称:Pitanzas,代码行数:25,代码来源:server-config.ts
示例5:
maxLogSize: config.log4js.maxLogSize,
backups: config.log4js.backups,
category: [ 'server', 'console' ]
},
],
replaceConsole: true
});
var logger = log4js.getLogger('server');
app.use(log4js.connectLogger(logger, {
level: log4js.levels.DEBUG,
nolog: [ '\\.css', '\\.js', ],
format: JSON.stringify({
'date': ':date',
'remote-addr': ':remote-addr',
'method': ':method',
'url': ':url',
'http-version': ':http-version',
'status': ':status',
'content-length': ':content-length',
'user-agent': ':user-agent'
})
}));
app.set('port', process.env.PORT || config.server.listenPort);
app.enable('trust proxy');
app.use(methodOverride());
app.use(cookieParser('jrpcMockServer'));
app.use(bodyParser.json());
app.use(session({
secret: 'jrpcMockServer',
开发者ID:uievolutionkk,项目名称:jsonrpc-mock-server,代码行数:32,代码来源:app.ts
注:本文中的log4js.connectLogger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论