cloudfoundry / routing-release

This is the BOSH release for cloud foundry routers
Apache License 2.0
42 stars 107 forks source link

[gorouter] Syslog writer sends empty logs #405

Open maxmoehl opened 2 months ago

maxmoehl commented 2 months ago

Current behavior

When configuring gorouter to send access logs via syslog, every log will be followed by an empty log. This is due to the access log record writing two times, once for the actual log and once for the new line (which is intended for the file writer): https://github.com/cloudfoundry/gorouter/blob/2ae1647bff83f6fdb4e45eb18ea5d0452e661e77/accesslog/schema/access_log_record.go#L358-L365

Desired behavior

When writing logs to syslog there is no need to append a new line and it should be omitted.

Affected Version

0.295.0

maxmoehl commented 2 months ago

On a side note, it seems like cloudfoundry/gorouter#329 never really wen't into effect, the PerformTruncate option of the custom writer is never passed on to the access log writer 😄

I'd propose to adjust those writers a bit: the writer itself expects to get one access log per call to Write. When writing to file, a new line is appended and when writing to syslog we just keep the log as-is. The syslog writer can then also truncate the log at the desired length.

maxmoehl commented 2 months ago

I've started cloudfoundry/gorouter#411 to address this issue.