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

How do I enable log rotation? #107

Closed
revington opened this issue Jan 24, 2014 · 5 comments
Closed

How do I enable log rotation? #107

revington opened this issue Jan 24, 2014 · 5 comments

Comments

@revington
Copy link

newrelic_agent.log is growing very fast in our set up. How I can enable log rotation?

@othiym23
Copy link
Contributor

Right now, there's no way to set up log rotation from within the agent yourself. You can use logrotate or similar tools to manage the New Relic logs like any other process's, although that requires a server restart. You can also manually upgrade the newrelic module to use the newest version of bunyan and then do some light hacking of lib/logger.js to set up a rotation policy. We use the last version of bunyan that doesn't depend on dtrace-provider, because while dtrace-provider is an optional dependency, its presence complicates deploying to PaaS environments where no toolchain is present, at least in terms of support.

Finally, you can try just setting the logging level to be 'info' or 'warn', if you're not already. Higher levels are really only useful for troubleshooting, and will slow down your app in production to boot. If it's logging too much at 'info' or higher, we probably need to make the module less chatty.

Thanks for getting in touch! Sorry we don't have a more immediately satisfying resolution!

@revington
Copy link
Author

Ok, not going to hack into lib/logger.js probably redirecting to stderr and piping stderr to https://github.com/dstokes/logrotate-stream is good solution.

@othiym23
Copy link
Contributor

That's a great idea! Let us know how that goes and maybe we'll add a note to the documentation!

@Azrael808
Copy link

Just came across this issue and wondered if the trick to not requiring a server restart if opting for the logrotate option is to simply add the "copytruncate" parameter to the configuration?

That's how Ruby application logs can be rotated without requiring a server restart, so I would assume it would work the same with the NewRelic Ruby agent. I'll give it a go and let you know!

@Azrael808
Copy link

So, my initial tests seem to suggest that does work. Example config:

/path/to/logs {
daily
missingok
rotate 7
compress
dateext
notifempty
copytruncate
}

cmcadams-newrelic pushed a commit to cmcadams-newrelic/node-newrelic that referenced this issue Jan 29, 2024
…/messaging-app/semver-5.7.2

chore(deps): bump semver from 5.7.1 to 5.7.2 in /messaging-app
jsumners-nr pushed a commit to jsumners-nr/node-newrelic that referenced this issue Apr 11, 2024
remove standalone capability and improved test coverage
jsumners-nr pushed a commit to jsumners-nr/node-newrelic that referenced this issue Apr 16, 2024
…/urijs-1.19.8

Bump urijs from 1.19.7 to 1.19.8
bizob2828 pushed a commit to bizob2828/node-newrelic that referenced this issue Apr 19, 2024
bizob2828 pushed a commit to bizob2828/node-newrelic that referenced this issue Apr 23, 2024
bizob2828 added a commit to bizob2828/node-newrelic that referenced this issue Jul 26, 2024
…/json5-2.2.3

Bump json5 from 2.2.1 to 2.2.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants