timberjack icon indicating copy to clipboard operation
timberjack copied to clipboard

[FEATURE] Custom time format and prefix and suffix in log file

Open Nyx2022 opened this issue 11 months ago • 1 comments

💡 Feature request

i wanna Custom time format in log file


// Example
tj := &timberjack.Logger{
    Filename:    "app.log",
    RotateEvery: time.Hour, // new option for fixed-interval rotation
    TimeFormat:"2006-03-04 15:06:07",
    Prefix:"[",
    Suffix:"]",
}

which can has the timestr like: [1999-10-02 10:00:00] in logfile

Nyx2022 avatar Dec 20 '25 09:12 Nyx2022

@Nyx2022 Thanks for the suggestion!

Timberjack is intentionally focused on log file rotation and lifecycle, not log content formatting. Timestamp formats, prefixes, and suffixes are typically handled by the logger writing to Timberjack (log, zap, zerolog, etc.), which already offer flexible formatting options.

For a single or niche use case, I prefer not to expand Timberjack’s config surface. A better approach would be:

  • Configure your logger to emit [2006-01-02 15:04:05] directly, or
  • Use a small script/sidecar to post-process newly rotated files if needed.

DeRuina avatar Jan 05 '26 14:01 DeRuina