Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filesize logrotate and log only specified level option #451

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

filesize logrotate and log only specified level option #451

wants to merge 3 commits into from

Conversation

odinn1984
Copy link

This PR adds support for log rotation with file size limitation additionally to the period of time rotation.

Also, add support to log only the specific log level (e.g: log only WARN), this is a global setting that will affect all streams.

Will create a patch in the future to add per stream support if will be required.

Levan Giguashvili added 2 commits October 22, 2016 19:04
#1)

* add support for rotating by file size and for logging only set level (global setting)

* update README, coding style, fix rotate size
@@ -333,6 +333,8 @@ function isWritable(obj) {
* See README.md for full details.
* - `level`: set the level for a single output stream (cannot be used
* with `streams`)
* - `logOnlySetLevel`: Use level as the only level to log and not a
* threshold (Defaut: false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default

@tomeresk
Copy link

I've been hoping for file size based rotation for a while, hope this gets merged

@@ -892,7 +892,8 @@ var log = bunyan.createLogger({
type: 'rotating-file',
path: '/var/log/foo.log',
period: '1d', // daily rotation
count: 3 // keep 3 back copies
count: 3, // keep 3 back copies,
maxSizeKB: 1024 // rotate every 1024KB
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should add a proper explanation of what the "maxSizeKB" attribute does.
If you expand the code below, you'll see:

"Currently, there is no support for providing a template for the rotated files, or for rotating when the log reaches a threshold size."

Which is no longer true.

@@ -333,6 +333,8 @@ function isWritable(obj) {
* See README.md for full details.
* - `level`: set the level for a single output stream (cannot be used
* with `streams`)
* - `logOnlySetLevel`: Use level as the only level to log and not a
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't use any attribute "logOnlySetLevel".
Should it be "logOnlyMinLevel"?

@@ -892,7 +892,8 @@ var log = bunyan.createLogger({
type: 'rotating-file',
path: '/var/log/foo.log',
period: '1d', // daily rotation
count: 3 // keep 3 back copies
count: 3, // keep 3 back copies,
maxSizeKB: 1024 // rotate every 1024KB
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might also consider adding some instructions explaining how and where to set "logOnlyMinLevel" parameter.
I'm sorry if it's obvious and I didn't get it. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants