小编lok*_*ath的帖子

将控制台日志以角度 2 移动到 kibana

我对 angular 2 有一个要求,例如,我想将所有控制台日志移动到像 Logstash 这样的服务器,并想在 Kibana 中查看这些日志。创建我自己的日志服务如下。

import { Injectable } from '@angular/core';

@Injectable()
export class LoggerService {
    enabled = true;
    noop = () => {};

    constructor() {
                // You can do a check on your environment or some other flag to 
                // enable/disable logging
        // if ((<any>'<%= ENV %>') === 'prod') this.enabled = false;
    }

    get debug() {
        if (this.enabled) return console.debug.bind(console);
        return this.noop;
    }

    get error() {
        if (this.enabled) return console.error.bind(console);
        return this.noop;
    }

    get log() { …
Run Code Online (Sandbox Code Playgroud)

kibana angular

6
推荐指数
0
解决办法
1561
查看次数

标签 统计

angular ×1

kibana ×1