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 to setup log rotation #303

Open
gbieli opened this issue Jul 15, 2019 · 5 comments
Open

How to setup log rotation #303

gbieli opened this issue Jul 15, 2019 · 5 comments
Assignees
Milestone

Comments

@gbieli
Copy link
Contributor

gbieli commented Jul 15, 2019

Hi

I'm using napalm-logs 0.7.0 as a system service on CentOS 7. How should I setup a proper log rotation? Are there options to configure? What is the best practice solution?

Current config:
cat /usr/lib/systemd/system/napalm-logs.service

[Unit]
Description=napalm-logs
Documentation=https://napalm-logs.readthedocs.io/en/latest/
After=network.target

[Service]
ExecStart=/usr/bin/napalm-logs
Type=simple
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

cat /etc/napalm/logs

log_level: info
port: 514
disable_security: true
extension_config_path: /etc/napalm/additional_config/
device_whitelist:
  - ios
  - opengear
publisher:
  http:
    address: 'http://elk.<snip>.<snip>:8080'
    method: POST
    headers:
      Content-Type: application/json
    backend: requests
    send_raw: true
    error_whitelist:
      - RXDATA
      - UNKNOWN
      - RAW
  zmq:
    address: 0.0.0.0
    port: 49017
    error_blacklist:
      - RXDATA
@mirceaulinic
Copy link
Member

Hey @gtcat - could you clarify what log rotation are you talking about? Are you referring to the napalm-logs log file /var/log/napalm/logs (http://napalm-logs.com/en/latest/options/index.html#log-file)?

@mirceaulinic mirceaulinic added this to the DISCUSSION milestone Sep 2, 2019
@gbieli
Copy link
Contributor Author

gbieli commented Sep 9, 2019

@mirceaulinic - yes I'm referring to the log file /var/log/napalm/logs. Sorry, I forgot to mention that.

@mirceaulinic
Copy link
Member

Ah, alright, in that case you might want to take a look at logrotate: https://linux.die.net/man/8/logrotate

@gbieli
Copy link
Contributor Author

gbieli commented Sep 11, 2019

I used logrotate for other Python applications written by myself and I had to use logging.handlers.WatchedFileHandler in my code because the application needs to be aware of the file being rotated. I already tried logrotate for napalm-logs and the result was that logging did not work anymore after the file has been rotated. A workaround would be to restart the napalm-logs daemon after rotation, but that does not seem to be an optimal solution to me.

I guess the logging code in napalm-logs should be adapted to support logrotate properly.

@mirceaulinic
Copy link
Member

Interesting, wasn't aware of this.

@mirceaulinic mirceaulinic reopened this Sep 18, 2019
@mirceaulinic mirceaulinic modified the milestones: 0.8.0, 0.9.0 Nov 29, 2019
@mirceaulinic mirceaulinic self-assigned this Nov 29, 2019
@mirceaulinic mirceaulinic modified the milestones: 0.9.0, APPROVED Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants