Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

node-graylog

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-graylog

node版graylog

latest
npmnpm
Version
2.0.8
Version published
Weekly downloads
33
17.86%
Maintainers
1
Weekly downloads
 
Created
Source

node-graylog

globalConfig(options)

用于设置全局配置

options

  • graylogHost graylog服务端host,默认127.0.0.1
  • graylogPort graylog服务端口号,默认值80
  • file 文件名
  • app 应用名
  • env 环境,可选
  • cluster 集群,可选
  • console 是否将日志输出到colsole控制台,默认为true
  • level 输入日志的最低日志级别,低于此级别的日志不会输出到graylog与控制台,默认info,可选debug、info、warn、error、critical
  • pool 可选,详细参数见generic-pool opts部分,默认max = 10, min = 2

getLogger(key, options)

  • key 日志实例唯一标识
  • options 同上

使用示例

const LoggerFactory = require('node-graylog');
// 设置全局配置
LoggerFactory.globalConfig({
  file: 'app.log',
  app: 'prelude',
  graylogHost: '10.57.17.76',
  graylogPort: 80,
  level: 'info'
});

const logger = LoggerFactory.getLogger('node.test');

logger.info('测试一下');
logger.warn('再测试一个');
logger.debug('最后就测这一个了');
logger.error('这是测试一个128个字符的测试用例这是测试一个128个字符的测试用例这是测试一个128个字符的测试用例这是测试一个128个字符的测试用例这是测试一个128个字符的测试用例这是测试一个128个字符的测试用例这是测试一个128个字符的测试用例这是测试一个128个字符的测试用例。')
const LoggerFactory = require('node-graylog');
const logger = LoggerFactory.getLogger('redis-client', {
  file: 'client.log',
  app: 'test',
  graylogHost: '10.57.17.76'
});
logger.error('这还是个测试');

其他

日志最大长度为1420 * 128,超过部分将会被截断

Keywords

node

FAQs

Package last updated on 10 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts