How to rotate Engine.log

I noticed that the Engine.log in '~/Library/Logs/Keyboard Maestro' is getting quite large and contains entries that date several years back.

Since Keyboard Maestro doesn’t seem to rotate the log itself, what’s the best way to have it rotated automatically on a regular basis to keep its size under control?

I have never encountered that issue so I hope other replies will explain what is going wrong there. If all else fails, though: you could have a macro move and/or rename the log file (adding the current date) and KM would just create a new Engine.log file as soon as it has something to log.

Frankly, I didn’t consider this an “issue” – just the way KM operates. Does that mean your Engine.log is not retaining years-old entries and growing indefinitely?

I usually try not to pull log files out from under running processes – that’s often not a good idea. But now that you mentioned simply deleting it, I checked Activity Monitor, and it does indeed look like Keyboard Maestro Engine is not keeping Engine.log open at all times.

That means I could just do this the standard way and use macOS’s newsyslog to rotate the log file on a weekly or monthly basis without having to worry about what that might do to KM.

Precisely. But who knows, maybe it’s my situation that’s the odd one out! I don’t think so though, and it sounds like a bit of an “issue” to me.

Yes, this has come up before, and I also tested on my system that removing the log did not upset KM before I replied, with no unexpected consequences.

I don’t think you need to worry at all (KM is not a diva!) but sure, use whatever you are most comfortable with and consider to be best practice.

Keyboard Maestro does rotate the log, it is kept under 13MB.

No need to do anything with it, it will never grow past that size.

2 Likes

Good to know – thanks for the info!

Hi, @mfichtner. When you mentioned rotate were you referring to the following process?


If that's the case, I don't think that's how Keyboard Maestro operates. @peternlewis, please correct me if I wrong. I haven't been able to find this information in the wiki.


@mfichtner, you might find this macro useful: Engine.log Tool

Keyboard Maestro rotates the log within the single file.

It does not, as some log rotations work, rotate the log by renaming the log file to a numbered sequence, each sequential log file to the next number, dropping the last of the sequence, and starting a new log.

When the log file gets past 13MB, it is trimmed back to the last 7MB or so.

I can't imagine anyone desiring to save old backups of the log file to ensure they don't lose data from more than 7MB of log data ago.

So there is no need to do anything to limit the log file size.

3 Likes

Yes, that’s what I had in mind. And it’s what newsyslog does. But in this particular case, I think @peternlewis’s solution is perfectly adequate. Engine.log is not nearly as important as, say, syslog or mail server logs, where you want to retain “historical” data. Doing full log rotation would be overkill when another method for controlling log file size is already in place.

That looks pretty impressive. I’ll definitely check it out – but not for this particular purpose.

1 Like

With older versions of MacOS, I think you could use newsyslog for third party logs. With Tahoe, however, I think you need to write your own shell script and use launchd.

But in your case, @mfichtner, it all seems to be moot.