consul icon indicating copy to clipboard operation
consul copied to clipboard

Log file option

Open carlivar opened this issue 12 years ago • 4 comments

Syslog support was added in #105 but that issue also asked for a log file option. I'd like this also.

Why do I want this? I'm in an old-school CentOS 5 & 6 init.d based environment. Snazzy new things like systemd and upstart aren't available which probably do a good job of capturing stdout/stderr to a file. runit is a possibility but I'm not thrilled about building and installing that just for Consul.

So what's exactly the problem? I can only log to a file now through appending stdout & stderr to a file and backgrounding the Consul process. Works great... until I want to use logrotate to rotate that file. I realized the only way I can release the file handle is a hard restart of Consul. That's not ideal, but possible. And then I realized, if I want to rotate logs regularly by time instead of size, all of my Consul agents could potentially be hard restarted at the same time by logrotate in order to release the file handle. Ouch.

I'm using syslog as a workaround, and perhaps could have syslogd log to a different file, but an explicit log file would be far simpler.

carlivar avatar Jul 28 '14 06:07 carlivar

Implementing different logging destinations in an application is generally not a good idea, IMO. There are many different requirements by different environments that could be easily (and should be) done by separate tools. If you don't mind nodejs, you can take a look at https://github.com/dstokes/logrotate-stream. I think there should be many similar tools out there.

salehe avatar Jul 28 '14 10:07 salehe

The stock logrotate can also perform a copy/truncate operations which is friendlier to a process that keeps the output file open.

jhmartin avatar Jul 29 '14 13:07 jhmartin

Thanks, I didn't know copy+truncate in logrotate. That's an option. And in that case this is just a "nice to have".

The main reason I filed an issue is because it was part of the request in #105 but was not implemented there.

carlivar avatar Jul 31 '14 18:07 carlivar

Agreed. For now, we'd prefer this problem to be handled outside of Consul using external tools.

armon avatar Aug 19 '14 17:08 armon