当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript log4js.configure函数代码示例

本文整理汇总了TypeScript中log4js.configure函数的典型用法代码示例。如果您正苦于以下问题:TypeScript configure函数的具体用法?TypeScript configure怎么用?TypeScript configure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了configure函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: errorLog

 /**
  * エラー内容をファイルに記述
  * @param err {String}エラー内容
  */
 static errorLog(err: string) {
     //ログ出力設定ファイル、log_config.jsonの読み込み
     log4js.configure(__dirname + '/log_config.json');
     //ロガー取得
     const errorLogger = log4js.getLogger('error');
     errorLogger.error(err);
 }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:11,代码来源:ControlLog.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: require

/// <reference path="../typings/main.d.ts" />
try { require("source-map-support").install(); } catch (e) { /* empty */ }
import {IncomingMessage, ServerResponse} from "http";
import * as connect from "connect";
import * as serveStatic from "serve-static";
import * as SocketIOStatic from "socket.io";
const socket: SocketIOStatic = require("socket.io");
import {configure, getLogger} from "log4js";
configure({
    appenders: [{ type: "console", layout: { type: "basic" } }],
    "levels": { default: "INFO" }
});
let logger = getLogger();
import direct from "./scene/director";


let httpPort = process.argv[2] || "3000";
let wsPort = process.argv[3] || "3001";
let app = connect();
app.use("/wsport", (req: IncomingMessage, res: ServerResponse) => {
    res.end(wsPort);
});
app.use(serveStatic("./lib/public/"));
app.listen(httpPort);
let io = socket(wsPort);
direct(io).catch(e => console.error(e.stack));
logger.info(`Server started: ${httpPort} ${wsPort}`);
开发者ID:progre,项目名称:sutahigashi,代码行数:27,代码来源:index.ts

示例4: init

 static init() {
     Log4js.configure(Path.join(__dirname, '../../logconfig.json'));
     Log.logger = getLogger('default');
     Log.logger.setLevel(Log4js.levels.DEBUG);
 }
开发者ID:winken168,项目名称:Hitchhiker,代码行数:5,代码来源:log.ts

示例5: getLogger

import * as log4js from 'log4js';

log4js.configure({
    appenders: [
        { type: 'console' },
        { type: 'file', filename: 'app.log', category: 'app' },
        { type: 'file', filename: 'app.log', category: 'mongo' },
        { type: 'file', filename: 'app.log', category: 'redis' },
        { type: 'file', filename: 'app.log', category: 'oracle' },
        { type: 'file', filename: 'app.log', category: 'ApplicationController'}
    ],
    // replaceConsole: true
})
export function getLogger(categoryName?: string): log4js.Logger {
    return log4js.getLogger(categoryName);
}
开发者ID:wangxin0709,项目名称:csc-scms-node-koa,代码行数:16,代码来源:logs.ts

示例6:

}

const isRoot = process.getuid && process.getuid() == 0

if (!isRoot) {
  log4js.configure({
    disableClustering: true,
    appenders: {
      out: {
        type: 'file',
        mode: 0o666,
        filename: LOG_FILE_PATH,
        maxLogSize: MAX_LOG_SIZE,
        backups: MAX_LOG_BACKUPS,
        layout: {
          type: 'pattern',
          // Format log in following pattern:
          // yyyy-MM-dd HH:mm:ss.mil $Level (pid:$pid) $categroy - $message.
          pattern: `%d{ISO8601} %p (pid:${process.pid}) [%c] - %m`,
        },
      }
    },
    categories: {
      default: { appenders: ['out'], level }
    }
  })
}

module.exports = (name = 'coc-nvim'): log4js.Logger => {
  return log4js.getLogger(name)
}
开发者ID:demelev,项目名称:coc.nvim,代码行数:31,代码来源:logger.ts

示例7: function

 .factory("$log", function() {
     let log4js = require("log4js");
     log4js.configure("log4js.json", { reloadSecs: 10 });
     let logger = log4js.getLogger();
     return logger;
 })
开发者ID:dconyers,项目名称:BalerDisplay,代码行数:6,代码来源:app.ts

示例8: default

export default (config: IExpressConfig) => {
  log4js.configure(config.log4js_config!);
  const logger = log4js.getLogger('express');
  const project_root = config.project_root + '/';
  const format = (req: express.Request, res: express.Response) => {
    if (req.skip_logging) {
      return '';
    }
    let e = res.error as any;
    let error_message;
    let error_stack;
    let error_cause_message;
    if (e) {
      error_message = e._code || e.message;
      if (!e._code && e.stack) {
        let stack: string = e.stack;
        stack = stack.substr(stack.indexOf('\n') + 1);
        const pos = stack.indexOf('response.setError');
        if (pos >= 0) {
          stack = stack.substr(stack.indexOf('\n', pos) + 1);
        }
        error_stack = stack.split('\n', 3).map((line) => {
          return line.replace(project_root, '').trim();
        });
      }
      e = e.cause;
      if (e) {
        error_cause_message = e.message;
      }
    }
    let url = req.originalUrl;
    const query_pos = url.indexOf('?');
    if (query_pos >= 0) {
      url = url.substr(0, query_pos);
    }
    if (url[url.length - 1] === '/') {
      url = url.substr(0, url.length - 1);
    }
    return {
      inspect() {
        let msg = `<${this.C.s.substr(0, 6)}> [${this.C.t}ms] ${this.C.a} - -`;
        msg += ` "${this.I.m} ${this.I.u} HTTP/${this.I.v}" ${this.O.s} ${this.O.l} "${this.I.r}" "${this.I.a}"`;
        msg += `\n\tI] q: ${JSON.stringify(this.I.q)}, b: ${JSON.stringify(this.I.b)}, f: ${JSON.stringify(this.I.f)}`;
        if (this.O.r) {
          msg += `\n\tO] ${JSON.stringify(this.O.r)}`;
        }
        if (this.O.e) {
          msg += `\n\tE] ${this.O.e}`;
          if (this.O.ec) {
            msg += ` CAUSED BY ${this.O.ec}`;
          }
          if (this.O.es) {
            msg += this.O.es.map((line) => {
              return '\n\t' + line;
            }).join('');
          }
        }
        return msg;
      },
      // connection
      C: {
        // remote_addr
        a: req.ip,
        // sessionID
        s: req.sessionID || '',
        // response_time
        t: res.responseTime,
      },
      // input(request)
      I: {
        // user_agent
        a: req.headers['user-agent'] || '',
        // body
        b: req.body || {},
        // files
        f: Object.keys(req.files || {}),
        // method
        m: req.method,
        // query
        q: req.query || {},
        // referrer
        r: req.headers.referer || req.headers.referrer || '',
        // url
        u: url,
        // http_version
        v: req.httpVersionMajor + '.' + req.httpVersionMinor,
      },
      // output(response)
      O: {
        // error.message
        e: error_message,
        // error_cause.message
        ec: error_cause_message,
        // error.stack
        es: error_stack,
        // content_length
        l: (res.__headers && res.__headers['Content-Length']) || '-',
        // result
        r: res.result,
        // status
//.........这里部分代码省略.........
开发者ID:croquiscom,项目名称:Crary-Node,代码行数:101,代码来源:logger.ts

示例9:

import * as http from 'http';
import * as path from 'path';
import * as mongoose from 'mongoose';
import * as log4js from 'log4js';
import * as cluster  from 'cluster';
import * as os from 'os';
import {Constantes as _ }  from './common/constantes';
import {AppConfig as config} from './config/app-config';
import {app as serverConfig} from './config/server-config'; 



/**CONEXIONES EXTERNAS */

//logger configuracion
log4js.configure(path.join(__dirname,_.CONFIG_LOG_FILE));
let logger = log4js.getLogger("server");
logger.info("Configurando server para entorno", process.env.NODE_ENV || _.ENTORNO_DEV);

//conexion BBDD
mongoose.connect(config.key(_.MONGO_URL));
let db = mongoose.connection;
//Se captura en evento si hay error cuando se intenta conectar 
db.on('error',error=> {logger.error("Error al conectar BBDD", error);});
//se captura el evento open pero con el "once" (en vez de on) significa que solo ejecuta manejador la primera vez 
db.once('open', ()=> {logger.info("Conectado a la BBDD", config.key(_.MONGO_URL));});



/**
 * Ventajas de crear un cluster, 
开发者ID:migueluvieu,项目名称:Pitanzas,代码行数:31,代码来源:server.ts

示例10: configure

import { configure, getLogger } from 'log4js';
configure({
  appenders: { console: { type: 'console', layout: { type: 'basic' } } },
  categories: { default: { appenders: ['console'], level: 'debug' } },
});
const logger = getLogger();
import * as fs from 'fs';
import * as http from 'http';
// tslint:disable-next-line:variable-name
const Gitter = require('node-gitter');
import { postStatus } from './gitterinterface';
import { getLatests, getSince } from './twitterinterface';

if (process.env.GITTER_ROOM == null
  || process.env.GITTER_TOKEN == null
  || process.env.TWITTER_CONSUMER_TOKEN == null
  || process.env.TWITTER_CONSUMER_SECRET == null
  || process.env.TWITTER_ACCESS_TOKEN_KEY == null
  || process.env.TWITTER_ACCESS_TOKEN_SECRET == null) {
  logger.fatal('Tokens not found.');
  process.exit(1);
}

http.createServer((_, res) => {
  const gitterToken = process.env.GITTER_TOKEN!;
  const twitterTokens = {
    consumerKey: process.env.TWITTER_CONSUMER_TOKEN,
    consumerSecret: process.env.TWITTER_CONSUMER_SECRET,
    accessTokenKey: process.env.TWITTER_ACCESS_TOKEN_KEY,
    accessTokenSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
  };
开发者ID:progre,项目名称:peca-voice,代码行数:31,代码来源:serve.ts


注:本文中的log4js.configure函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。