Skip to content

Conversation

aeris
Copy link

@aeris aeris commented Sep 6, 2025

Lumberjack is unmaintained since 2 years.
A fork exists, Timberjack to replace it with more features.

This PR migrate to Timberjack and add support newest features, specially RotateAt options to allow to rotate log file base on date.

Assistance Disclosure

No AI was used.

@CLAassistant
Copy link

CLAassistant commented Sep 6, 2025

CLA assistant check
All committers have signed the CLA.

@francislavoie
Copy link
Member

Oh, fantastic! I didn't get the memo that a fork was worked on, we were waiting for someone to pick up the mantle. Will review soon.

Comment on lines 107 to 108
// Roll log file at fix time
RollAt []string `json:"roll_at,omitempty`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what the inputs are here. What are the values supposed to be? The godoc comment here should be fleshed out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering my own question, it looks something like this in timberjack

RotateAt:         []string{"00:00", "12:00"}, // Also rotate at 00:00 and 12:00 each day

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc added for this config param in 6ff7126

// How many days to keep rolled log files. Default: 90
RollKeepDays int `json:"roll_keep_days,omitempty"`

// Rotated file will have format <logfilename>-<format>-<criterion>.log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should explain that the default from timberjack is:

// Optional. If unset or invalid, defaults to 2006-01-02T15-04-05.000 (with fallback warning)

Also mention that the <format> must be a Go time compatible format described here https://pkg.go.dev/time#pkg-constants

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add doc & link to go doc in 6ff7126

Comment on lines 104 to 114
// Roll log file at fix minutes
RollAtMinutes []int `json:"roll_at_minutes,omitempty"`

// Roll log file at fix time
RollAt []string `json:"roll_at,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These godoc comments should cover some of the caveats mentioned in the timberjack README https://github.com/DeRuina/timberjack#%EF%B8%8F-rotation-notes--warnings (and eventually also in the Caddy website docs)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also subtleties like using either of RollAt/RollAtMinutes will use a background goroutine to trigger rotation, whereas RollInterval triggers a check on each log write whether the interval has been crossed and causes a rotation at that point (no goroutine).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ff7126

@francislavoie francislavoie changed the title Move to timberjack and add rotate-at methods logging: Switch from lumberjack to timberjack add time-rolling options Sep 7, 2025
@francislavoie francislavoie changed the title logging: Switch from lumberjack to timberjack add time-rolling options logging: Switch from lumberjack to timberjack, add time-rolling options Sep 7, 2025
@francislavoie francislavoie added this to the v2.11.0 milestone Sep 14, 2025
@mholt
Copy link
Member

mholt commented Sep 17, 2025

This is looking great. I am happy to merge this, I just need to give it one closer look first.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok yeah this looks great. Thank you!

I second Francis' comments -- if we can clarify some docs and address the things he brought up, I'd say let's merge it. 👍

@aeris
Copy link
Author

aeris commented Sep 18, 2025

👍 I try to fix docs & cie this week-end !

@francislavoie
Copy link
Member

Thanks!

FYI timberjack had a new release just now to add support for zstd compression (we should expose that option too) & adding a reason to manual rotation (so we could add support for rotating the files on config reload).

Another requested nice-to-have, we could also add support for opt-in reopening of the log file on config reload, useful for when users use their own external log rolling instead of what we provide them, we should reopen the log file so it correctly points to the new file instead of the moved file.

@aeris aeris force-pushed the timberjack-rotate-at branch from 310f7df to 6ff7126 Compare September 30, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants