Skip to content

Syslog logging #10352

Closed
Closed

Description

@grawity

Feature description

The new logging framework doesn't seem to integrate with system logging at all. It only logs to stdout, which means it prefixes its own timestamps (even though the system already does that to all received log messages), and it doesn't have a way to fill in message priority (meaning that all messages – from debug to fatal error – become just 'info').

Would it be acceptable to add support to output log messages through Unix syslog() (e.g. --log-target=syslog, which currently I didn't find in syncthing serve --help)?

Problem or use case

Support for standard logging API would make it easier to read logs by 1) avoiding duplicate fields, and 2) allowing e.g. journalctl to highlight important messages in more obvious ways than just the 'WRN' field.

The latter would also allow existing "alert server owner on warning/error log messages" to function with Syncthing, without having to special-case syncthing's own log format.

Alternatives or workarounds

None.

Activity

  1. added theissue type on Sep 4, 2025
  2. added
    enhancement
    needs-triage
    on Sep 4, 2025
  3. calmh commented on Sep 4, 2025

    @calmh
    Member

    I think the only thing that changed in this respect in 2.0 is that you can't disable the timestamp now, which is a regression of sorts that we could address. Apart from that, I believe that a stream of text lines on stdout is the closest we have to a standard logging API today. I'm not keen on special things for syslog, Windows Event Log, what have you. For any sort of systematic / at scale deployment it might make sense to have a --log-json to make the log lines more fully machine readable, though.

  4. grawity commented on Sep 4, 2025

    @grawity
    Author

    Apart from that, I believe that a stream of text lines on stdout is the closest we have to a standard logging API today. I'm not keen on special things for syslog, Windows Event Log, what have you

    Syslog has been a "standard" logging API on Unix-like platforms for a good few years, though. It doesn't provide much in terms of machine-readability, but just having the message priority as its own field is a good first tier of filtering, and for many small deployments I don't think it is necessary to have further machine-readability beyond that – it would be enough to alert about 'all' errors and let the human take further action.

    Although in my case I'm running Syncthing through systemd, which supports specifying message priorities via stdout logging as well – although using numeric values like <5> (similar to what you'd see in BSD Syslog packets) rather than INF or info=.

    (But quite frankly, I've already seen several other programs claim that stdout logging is more standard, and yet every single app implements it differently.)

    For any sort of systematic / at scale deployment it might make sense to have a --log-json to make the log lines more fully machine readable, though.

    But I don't want "at scale" deployment, and I'm not asking for full machine readability. In fact it really baffles me that the only options are two extremes. I just want a desktop app to sync personal files between a few personal computers and a home NAS – I'm not going to run it through Kubernetes nor pipe the logs to a SIEM...

  5. bt90 commented on Sep 4, 2025

    @bt90
    Contributor

    I just want a desktop app to sync personal files between a few personal computers and a home NAS – I'm not going to run it through Kubernetes nor pipe the logs to a SIEM...

    Quoting Alan Kay: Simple things should be simple. Complex things should be possible.

  6. grawity commented on Sep 4, 2025

    @grawity
    Author

    I just want a desktop app to sync personal files between a few personal computers and a home NAS – I'm not going to run it through Kubernetes nor pipe the logs to a SIEM...

    Quoting Alan Kay: Simple things should be simple. Complex things should be possible.

    Am I asking for anything to the contrary?

  7. calmh commented on Sep 4, 2025

    @calmh
    Member

    Although in my case I'm running Syncthing through systemd, which supports specifying message priorities via stdout logging as well – although using numeric values like <5> (similar to what you'd see in BSD Syslog packets) rather than INF or info=.

    Frankly I'd be more inclined to support this, as it's a simple tweak to our log formatter that we could easily enable with --log-systemd or something.

  8. grawity commented on Sep 4, 2025

    @grawity
    Author

    Although in my case I'm running Syncthing through systemd, which supports specifying message priorities via stdout logging as well – although using numeric values like <5> (similar to what you'd see in BSD Syslog packets) rather than INF or info=.

    Frankly I'd be more inclined to support this, as it's a simple tweak to our log formatter that we could easily enable with --log-systemd or something.

    That would be very useful to have. The format is <%d> (without any space separator), the integer value being the same levels as in syslog:

    <7>  debug
    <6>  info (default)
    <5>  notice
    <4>  warning
    <3>  error
    <2>  critical
    <1>  alert
    <0>  emerg
    

    IIRC, current systemd versions interpret this prefix for all services' stdout logs without having to enable anything. Previously it was a SyslogLevelPrefix= option. For testing systemd-cat also does the same.

    Though --log-systemd might cause confusion with the actual systemd structured logging API, but I'm not sure of a better name, maybe --log-level-prefix.

    (I'm not relaly familiar with how logging is done at scale – on my own home server I just have a basic hand-made setup where anything >= error in the system log gets emailed to me daily and >= alert goes to a Discord push notification. So for example I get notified about some service OOM-crashing, based solely on the message levels, without specifically needing to parse any message contents.)

  9. added 6 commits that reference this issue on Sep 4, 2025
    6cfcf7d
    546b832
    cbc3af4
    f49bcce
    4963b18
    35d383f
  10. added a commit that references this issue on Sep 5, 2025
    3625447
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds-triage

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions