So, before I begin at all, I’ll admit one thing right off the bat: I was already having a poor day. Even though I’m no expert in the detailed inner workings of Java classes, I have a minimal set of expectations when it comes to consistency. If I replace instances of CachedThreadPool with FixedThreadPool, I expect the behavior to be somewhat consistent aside from the numbers of issued threads. What I don’t expect is the garbage collector to ignore the expired instances of FixedThreadPool, resulting in a memory leak and reaching the ulimit maximum on processes/threads allowed by the system. (Apparently, this issue goes back several years, and it hasn’t been addressed yet.) So, after spending hours in order to diagnose the problem, I had already reached a point of being slightly annoyed. However, I only had one small task to accomplish during the remainder of my day: I needed to change the log4j policy of my Java project, so that any old log files would automatically be removed past a certain age. So, it’s safe to say that I believed the annoying part of the day was over. I was wrong.
My log4j policy was set to the daily rolling of log files, and I looked online for an example of a policy that also used the “maxbackupindex” value. When I didn’t find one, I was slightly confused as about its absence online, and in pursuit of an answer, I went to a colleague who was more familiar with all of the latest trends in Java. It had only been a few weeks ago that he had correctly steered me from using log4j directly to instead using its sfl4j wrapper. “Oh, no,” he said. “You can’t use the ‘maxbackupindex’ value with the daily rolling in log4j.” I didn’t understand why ‘maxbackupindex’ worked with only size rolling files, since the delete functionality should only need to consider files in terms of time instead of size…but I shrugged in response to my own disappointment. Instead, I asked if he thought that it would ever be fixed. “Oh, it has,” he responded. “Some of the same guys who made log4j created a new project called logback, and they support the use of ‘maxbackupindex’ with daily rolling. You can switch to that one now.”
They did what? Instead of addressing the old project, they created yet another new library that I should switch to? At that moment, my day soured even more at the thought of the distant future and its trillion Java libraries, where each library is only a slightly different iteration of a previous one. Now, before I say anything else, let it be known that I have always loved the open source movement. Decades ago (in the early years), I contributed to it, and I have always spoken volumes about its honorable merit and its positive impact on the business world and scientific community…but there are those moments where I shake my head in disbelief at its disorganization and redundancy. In the end, though, I’ll probably make the eventual switch to using logback…or, just for laughs, maybe I’ll go ahead and create the next great Java logging package, in order to add one more library to the pile.