Opened 7 years ago

Closed 5 years ago

#5583 closed enhancement (implemented)

Add option to overwrite logs

Reported by: bastik Owned by:
Priority: Medium Milestone: Tor: 0.2.6.x-final
Component: Core Tor/Tor Version: Tor: unspecified
Severity: Keywords: overwrite log safer logging tor-relay small-feature easy
Cc: bastik Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Add an option to make Tor overwrite logs, instead of appending them.

For instance whenever Tor gets restarted and this option is enabled the log does not get appended.*

This should enable operators to log without the risk of month old logs. Even when not enabled by default, what I was looking for in the first place, as I had not understood why logs are appending, it might help to have this option available.

The same applies to the client, once I was asked to provide logs from my client, and got told afterwards to remove the logging entry from torrc. When that does not happen, the client is logging for eternity and therefor provides an usage history due to the fact that the log is appending.

I couldn't pick "Tor" for "Component"; for me it's client and relay related.

*Other ways like, logging for a 24 hour period, keep this period and delete the lines that are older, might bring more problems than it's worth.

Child Tickets

Attachments (1)

0001-Add-an-option-to-overwrite-logs.patch (8.1 KB) - added by arlolra 5 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 7 years ago by nickm

Milestone: Tor: 0.2.4.x-final

Seems like a good idea; marking for 0.2.4.x since it's a feature.

comment:2 Changed 7 years ago by nickm

Keywords: tor-relay added

comment:3 Changed 7 years ago by nickm

Component: Tor RelayTor

comment:4 Changed 6 years ago by nickm

Keywords: small-feature added

Anybody want to try to squeeze this in by the small-feature deadline?

comment:5 Changed 6 years ago by nickm

Milestone: Tor: 0.2.4.x-finalTor: unspecified

comment:6 Changed 6 years ago by arma

The only Tor packages that log to a file should also have logrotate support, yes?

It seems weird to do this feature inside Tor.

comment:7 in reply to:  6 Changed 6 years ago by bastik

Replying to arma:

The only Tor packages that log to a file should also have logrotate support, yes?

Isn't it possible to log to file with any Tor bundle/package?

Rotating logs would be an interesting feature. This ticket shouldn't be about this, but I would not mind.

It seems weird to do this feature inside Tor.

I don't know about the plans... it would be better if that would not be inside Tor; however this works across platforms having it outside Tor.

comment:8 Changed 5 years ago by nickm

Keywords: easy added

See also #2914; tagging as "easy". I think we should at least do this much.

comment:9 Changed 5 years ago by arlolra

Status: newneeds_review

Please see the attached.

comment:10 Changed 5 years ago by nickm

Milestone: Tor: unspecifiedTor: 0.2.6.x-final

Thanks for the patch! Marking for possible inclusion in 0.2.6.

comment:11 Changed 5 years ago by nickm

Status: needs_reviewneeds_revision

As written, I think this patch will truncate the logs not only at startup, and not only when receiving a SIGHUP, but also every time any option is changed from the controller.

One easy fix would be to define this option as startup-only. I'm not sure that would give people the semantics they expect if they add new logs at runtime, though.

Changed 5 years ago by arlolra

comment:12 in reply to:  11 Changed 5 years ago by arlolra

Replying to nickm:

As written, I think this patch will truncate the logs not only at startup, and not only when receiving a SIGHUP, but also every time any option is changed from the controller.

Ah, I see what you mean. I updated the patch to address that concern.

comment:13 Changed 5 years ago by arlolra

Status: needs_revisionneeds_review

Hrm, forgot to change the status.

comment:14 Changed 5 years ago by nickm

Resolution: implemented
Status: needs_reviewclosed

Merged!

I'm not completely sure that overwrite-on-sighup is what people want with this option, but I'm also not sure it isn't what people want. We can tweak the UI if that behavior isn't desired, I guess.

As for the ftruncate call -- we need to be a little careful there, since not all ftruncate() versions behave the same, and windows doesn't have ftruncate. I did a portable ftruncate in 867f5e6a7602fe5cf54686aa04995eaabaea4c80.

Note: See TracTickets for help on using tickets.