routing-release icon indicating copy to clipboard operation
routing-release copied to clipboard

[gorouter] Syslog writer sends empty logs

Open maxmoehl opened this issue 1 year ago • 2 comments

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 avatar Apr 18 '24 13:04 maxmoehl

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 avatar Apr 18 '24 13:04 maxmoehl

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

maxmoehl avatar Apr 19 '24 07:04 maxmoehl

Fixed it!

ameowlia avatar Dec 18 '24 16:12 ameowlia