Unsolicited log file rotation

(duplicated from the Lucee subchannel on the CFML slack @ @Zackster’s suggestion):

Hi I have a log file I am writing to just with writeLog(file="mylogfile"...). This log is not configured in Lucee Admin at all, so it should have no log rotation going on.

However I just checked and it looks like Lucee has rotated it: there is a mylogfile.log.1 in the log dir now.

I also can’t see what the rules for the rotation are. The file is 2128078 bytes, which is not a unit of MB, and it’s been rotated in the middle of the afternoon (rather than across the end of the day or something).

Can I please get some clarification as to what’s up here? We really don’t want that log rotated by Lucee… all that is already in hand via another mechanism.



there’s a max file size which is checked when a logfile resourceAppender is created, they aren’t created for every log call, hence the non round number


I think a default behaviour of [doing anything] with the log file is maybe questionable, but so be it I guess.

I still don’t understand how we’d get a log file rotation kicking in @ 2MB when the default is 10MB.

Also given it’s the act of adding a log entry that grows the file, that is when the check of whether it’s time to rotate should occur, right? Not when “a logfile resourceAppender is created”, which would… I’m guessing… only occur the once for the lifetime of the server? I presume it’s something that happens when the first call to log to a given log is made? This sounds like a bug to me, based on what you say & me inferring from there.

But if a log is going to default to rotating every 10MB and have a max of ten files. How do I disable that? Or would it be a matter of setting the max size to [very large value] and, the max files to be 1? Does 1 for max files mean “log file plus one” or “just the log file and that’s it. Don’t rotate”. Or if I did that, would Lucee actually clear the main log file when it got full, so as to respect the max size? I can probably test that part myself (which I will do, and report back).



but is the answer to just define the the log file in the admin, which (may) expose the configuration flexibility you’re after?

Well yeah to do the “[very large value] and, the max files to be 1” I’d need to add some config to it anyhow. Can’t do it via the admin (because it’s 2022 if for no other reason), but the Administrator object route (as per Adam Cameron's Dev Blog: Lucee: Creating a log file programmatically) will work, provided I can coerce the correct settings.

That doesn’t answer any of my questions though.


yeah when i said admin, i meant at the context level

you can even define logs with all the options in application.cfc too

Adam, interesting points/observations. I do not disagree, 2 MB rotation vs 10 MB configured feels broken.

It sounds to me like another workaround may be using a file writer / append VS using log where you have more control of the situation / rotation may work for you.

1 Like

Ha! So there is. I did not find that in any of my googlings, but I see it now: Application.cfc / <cfapplication> :: Lucee Documentation

[topic moved to Configuring log files in Application.cfc]



I’d love to see what structure/code you come up with as it could be useful info for the community.

Also we’re getting sidetracked from the actual issue, which is the bit above. TBH, I’d rather this thread kept its focus on the subject.

OT but anyway, plz always share any NPEs with the top of the stacktrace, they should never happen

Nope, I’m staying on-topic on this thread. Started a new thread for this topic: Configuring log files in Application.cfc