Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Custom logger is not supported anymore #44

Closed
willmcclellan opened this issue Apr 28, 2016 · 10 comments
Closed

Custom logger is not supported anymore #44

willmcclellan opened this issue Apr 28, 2016 · 10 comments

Comments

@willmcclellan
Copy link

Contrary to the readme, it appears that custom loggers (bunyan, winston etc) are not supported anymore. From the history it looks as though this was removed in the 3.x.x release

@iCyberon
Copy link

@mderazon created a Bunyan stream, which might be useful. #21 (comment)

@watson
Copy link
Member

watson commented Apr 28, 2016

@willmcclellan You are absolutely right - that's a mistake 😞 I'll make sure this get re-added.

watson added a commit that referenced this issue Jan 3, 2017
This commit completely rewrites and unifies the internal logging code.
All output will now be in JSON format.

Opbeat no longer relies on the `debug` module for debug-level logging.
Instead all logging have now been rewritten to use the `pino` module and
the previous debug calls now use the debug-level on the pino module.

This means that the `DEBUG=opbeat` environment variable is no longer
supported. Instead set the `logLevel` config option to `debug` (or set
the equivalent `OPBEAT_LOG_LEVEL=debug` environment variable).

```js
require('opbeat').start({
  logLevel: 'debug'
})
```

By default the built-in logger will log to STDOUT. But using the new
`logFile` config option (environment variable: `OPBEAT_LOG_FILE`), it's
now possible to specify a file path or provide a writeable stream that
the log should be written to.

The `logFile` config option can also be set to one of the two magic
strings `stdout` or `stderr` in which case logs will be streamed to
either STDOUT or STDERR respectively.

```js
// log to a file specified by a path
require('opbeat').start({
  logFile: '/var/log/opbeat.log'
})

// log to a writable stream
require('opbeat').start({
  logFile: fs.createWriteStream('/var/log/opbeat.log')
})
```

It's now also (again) possible to supply a custom logger using the
`logger` config option. It's expected that the logger conforms to the
Log4j interface:

```js
require('opbeat').start({
  logger: require('bunyan')({level: 'info'})
})
```

Fixes #44
watson added a commit that referenced this issue Jan 7, 2017
This commit completely rewrites and unifies the internal logging code.
All output will now be in JSON format.

Opbeat no longer relies on the `debug` module for debug-level logging.
Instead all logging have now been rewritten to use the `pino` module and
the previous debug calls now use the debug-level on the pino module.

This means that the `DEBUG=opbeat` environment variable is no longer
supported. Instead set the `logLevel` config option to `debug` (or set
the equivalent `OPBEAT_LOG_LEVEL=debug` environment variable).

```js
require('opbeat').start({
  logLevel: 'debug'
})
```

By default the built-in logger will log to STDOUT. But using the new
`logFile` config option (environment variable: `OPBEAT_LOG_FILE`), it's
now possible to specify a file path or provide a writeable stream that
the log should be written to.

The `logFile` config option can also be set to one of the two magic
strings `stdout` or `stderr` in which case logs will be streamed to
either STDOUT or STDERR respectively.

```js
// log to a file specified by a path
require('opbeat').start({
  logFile: '/var/log/opbeat.log'
})

// log to a writable stream
require('opbeat').start({
  logFile: fs.createWriteStream('/var/log/opbeat.log')
})
```

It's now also (again) possible to supply a custom logger using the
`logger` config option. It's expected that the logger conforms to the
Log4j interface:

```js
require('opbeat').start({
  logger: require('bunyan')({level: 'info'})
})
```

Fixes #44
watson added a commit that referenced this issue Jan 13, 2017
This commit completely rewrites and unifies the internal logging code.
All output will now be in JSON format.

Opbeat no longer relies on the `debug` module for debug-level logging.
Instead all logging have now been rewritten to use the `pino` module and
the previous debug calls now use the debug-level on the pino module.

This means that the `DEBUG=opbeat` environment variable is no longer
supported. Instead set the `logLevel` config option to `debug` (or set
the equivalent `OPBEAT_LOG_LEVEL=debug` environment variable).

```js
require('opbeat').start({
  logLevel: 'debug'
})
```

By default the built-in logger will log to STDOUT. But using the new
`logFile` config option (environment variable: `OPBEAT_LOG_FILE`), it's
now possible to specify a file path or provide a writeable stream that
the log should be written to.

The `logFile` config option can also be set to one of the two magic
strings `stdout` or `stderr` in which case logs will be streamed to
either STDOUT or STDERR respectively.

```js
// log to a file specified by a path
require('opbeat').start({
  logFile: '/var/log/opbeat.log'
})

// log to a writable stream
require('opbeat').start({
  logFile: fs.createWriteStream('/var/log/opbeat.log')
})
```

It's now also (again) possible to supply a custom logger using the
`logger` config option. It's expected that the logger conforms to the
Log4j interface:

```js
require('opbeat').start({
  logger: require('bunyan')({level: 'info'})
})
```

Fixes #44
watson added a commit that referenced this issue Jan 13, 2017
This commit completely rewrites and unifies the internal logging code.
All output will now be in JSON format.

Opbeat no longer relies on the `debug` module for debug-level logging.
Instead all logging have now been rewritten to use the `pino` module and
the previous debug calls now use the debug-level on the pino module.

This means that the `DEBUG=opbeat` environment variable is no longer
supported. Instead set the `logLevel` config option to `debug` (or set
the equivalent `OPBEAT_LOG_LEVEL=debug` environment variable).

```js
require('opbeat').start({
  logLevel: 'debug'
})
```

By default the built-in logger will log to STDOUT. But using the new
`logFile` config option (environment variable: `OPBEAT_LOG_FILE`), it's
now possible to specify a file path or provide a writeable stream that
the log should be written to.

The `logFile` config option can also be set to one of the two magic
strings `stdout` or `stderr` in which case logs will be streamed to
either STDOUT or STDERR respectively.

```js
// log to a file specified by a path
require('opbeat').start({
  logFile: '/var/log/opbeat.log'
})

// log to a writable stream
require('opbeat').start({
  logFile: fs.createWriteStream('/var/log/opbeat.log')
})
```

It's now also (again) possible to supply a custom logger using the
`logger` config option. It's expected that the logger conforms to the
Log4j interface:

```js
require('opbeat').start({
  logger: require('bunyan')({level: 'info'})
})
```

Fixes #44
@jsumners
Copy link

Is there an ETA on the fix being released?

@jsumners
Copy link

ping: @watson

@watson
Copy link
Member

watson commented Mar 14, 2017

@jsumners Sorry about the slow reply. This have been held back by a refactoring process replacing the entire logging logic, which unfortunately is taking longer than expected.

We are trying to unify debugging logs and regular logs into the same logger (today we use the debug module for debugging).

At the same time we have experimented with switching to a json logger. This is not technically a big issue, but it means that all output will be json formatted. This is really helpfull when passing the logs programatically, but it's not that user-friendly when you're just reading it in the console.

Do you have any preferences in this matter?

@jsumners
Copy link

@watson as a maintainer of Pino, I want to use Pino. If you backport pinojs/pino#186 to the legacy release then you can easily make the output of this module's logs much prettier if the user hasn't supplied a logger.

As for debug logging of opbeat-node, I'd like to see them use the trace level.

@watson
Copy link
Member

watson commented Mar 14, 2017

@jsumners that PR might solve all our problems, thanks 😃 - I've been falling behind on that lately 😞

Regarding log level, why is your preference trace instead of debug?

@jsumners
Copy link

@watson When I enable debug logging for my application then I am concerned with debugging my actual application. So I don't want to see logs from supporting libraries unless I have determined that the bug is in a supporting library. At that point I will elevate logging to the trace level.

@watson
Copy link
Member

watson commented Mar 14, 2017

@jsumners Good point. Thanks for the feedback

@watson
Copy link
Member

watson commented Jun 12, 2018

Opbeat has joined forces with Elastic and this agent is therefore deprecated. So I'll go ahead and close this issue.

Our new product is called Elastic APM, it's open source, and the Node.js agent used there is based off this agent. Support for a custom logger have been re-added to the Elastic APM Node.js Agent, so if you're interested in trying out Elastic APM, we'd love your feedback.

@watson watson closed this as completed Jun 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants