Skip to content

修改至log4js-aliyun-log,适配log4js 2.0以上

Notifications You must be signed in to change notification settings

zsea/log4js-aliyun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

log4js-aliyun

修改至log4js-aliyun-log,适配log4js 2.0以上

安装

npm install log4js-aliyun --save

配置

{
      "type": "log4js-aliyun",
      "layout": {
        "type": "pattern",
        "pattern": "%p %c %m"
      },
      "aliyunKey":"aliyunKey",
      "aliyunSecret":"aliyunSecrect",
      "endpoint":"http://cn-hangzhou.sls.aliyuncs.com",
      "slsProject":"porjectname",
      "logStoreName":"logStoreName",
      "topic":"",
      "category": "test"
}

更多配置请参考aliyun sdk's js.

示例

var log4js=require('log4js');
var cfg={
    appenders:{
      "type": "log4js-aliyun",
      "layout": {
        "type": "pattern",
        "pattern": "%p %c %m"
      },
      "aliyunKey":"aliyunKey",
      "aliyunSecret":"aliyunSecrect",
      "endpoint":"http://cn-hangzhou.sls.aliyuncs.com",
      "slsProject":"porjectname",
      "logStoreName":"logStoreName",
      "topic":"",
      "category": "test"
    }
}
log4js.configure({
    appenders: { console: { type: 'console' }, sls: cfg.appenders },
    categories: { default: { appenders: ['console', 'sls'], level: "TRACE" }}
});

About

修改至log4js-aliyun-log,适配log4js 2.0以上

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published