當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。