Coder’s Corner: Using Log4j in a LibGdx project in Intellij – Gradle hiccup

Apparently stuxnet managed to hybridize in a way such that it’s taken Josh out for the foreseeable future. Either that or he succumbed to snowcrash. In any event, that means that Rho-Bot and I will be conquering our weekly blog for the foreseeable future. And starting our new and likely recurring segment: Coder’s Corner.

Earlier this week I was setting up our new project (no, we’re not going to squeal on what it is yet), and I wanted to use the Log4j libraries. My primary motivation for doing so is that I like data and, if I’m not the one doing the testing, I usually get incomplete descriptions of bugs back. Since libgdx’s built in logging only outputs to the console we need some way to create actual log files ergo Log4j. I’ve used these libraries in our earlier projects with no problems. But last week I started using Intellij as my IDE. This time, however, after I dropped the libraries and my config file into the same location as the last project and I got this error:

log4j error
ERROR StatusLogger No log4j2 configurationfile found. Using default configuration: logging only errors to the console.

I know what you’re computing ‘ACMU you forgot to add ?*.xml to the resource patterns in your compiler settings. As it happens, 0) I did not forget to do that, and 1) as I found out the next day it’s not strictly necessary to do that for Log4j anyway.
With that most obvious source of my difficulties out of the way I clicked over to the Log4j manual and it says

“If a JSON file cannot be located the XML ConfigurationFactory will try to locate log4j2.xml on the classpath.” 

So you’d think that if my project structure looks like this:

project structure
Whatever the next project is it’s safe to say it’s both bad and angry

the library would find a configuration file acceptable and use it. No dice (Did you processor that pun?). So I spent a few hours on stackexchange making no progress. Then, through some fluke, I read the Log4j configuration page again and realized that a line up at the top says,

“Log4j will inspect the “log4j.configurationFile” system property and, if set, will attempt to load the configuration using the ConfigurationFactory that matches the file extension.”

Alright so we’ll just got to Run->Edit Configurations, set our system property like this:

configuration options

Drop the config file into your working directory and voila, Log4j is configured.

The next morning when I got to work it occurred to me that a work project was using Log4j too. I had just started using Intellij at work too, and I didn’t remember having any configuration issues, so I did a little digging. I went looking for the project’s log4j2.xml file and found it sitting in the /src/ directory and I hadn’t even marked *.xml as a resource file type.

Which leads to the question, “What are the differences between these two projects?”. Well, at home I set up a libgdx project using gradle for dependency management; at work I just write code with no dependency management – because enterprise applications are boring. So, an alternate (and probably better) solution than the one I found is to include the Log4j configuration file as a resource in the gradle.build file. And no I’m not going to tell you how to do that. In the words of many a professor and textbook: it’s left as an exercise for the reader.

Stoned in Space Feburary

Rho_bot has been hard at work on the graphics and I think it’s safe to say that the artwork is done. While some final layout adjustments need to be made. Which means, of course, new and updated screenshots.

MainMenu
Is it a menu or a ship?
game screen feb
Filler graphics have been left where they belong, in November.

In other exciting news the sounds are pretty well wrapped up. All of this points to Stoned in Space going to beta testing sometime next week. We just have to do a few minor tweaks and an in game tutorial.

And that brings us to this month’s schedule update.

FebSchedPlot

Squinting at the right side you’ll notice the dramatic 2-3 month pull-in of the completion date in the last couple of days. Well, after the third straight month of push outs this time for no easily explainable reason I did a quick estimate of the expected completion date by hand on an envelope and found it to be near the beginning of March. Much closer than the scheduler was predicting. After a quick perusal of the scheduler’s code a bug was found and crushed, and henceforth schedules will be ‘totally accurate’. Well they’ll at least be somewhat more predictive at least.

Stoned in Space January

It’s a good news bad news month. Bad news is; We’re still not actually getting any closer to the completion date. This time due to really poor estimation on the schedule. Basically numerous tasks in the spec for the game were inappropriately rolled into one task and that task was allocated about 10% of the time it should have been. It’s possible that the Holidays didn’t help, but I don’t think that contributed to the bulk of the continued delay.  We now looking a release some time in April.

And we've turned into a real game development company the delivery date just keeps pushing out.
And we’ve turned into a real game development company; the delivery date just keeps getting pushed out.

For good news; rho_bot is back and has completed many of the graphics. With mostly screen backgrounds left I’m hoping those will be done by the end of January. We also have enough of the game together to start tweaking the difficulty, and we’re slowly moving away from the initial state of absurdly easy.

Also in an effort to prevent a further push out of the release at least initially some features will be dropped these will mostly be special asteroids or critters which hadn’t been well thought out in the first place, and the global leader board.

Stoned in Space December

Bad news we suffered a massive slow down due to holidays, and Rho_bot’s continued inaction on graphics, and me being required to put in extra time at let’s say my evening job. This meant that instead of coding I’ve been relearning how to use blender. Good news is I’ve gotten some graphics done: the game over background and a group of asteroids.  This has led to a predictable push out in Stoned’s completion date.

Surprise, Surprise, dicking around for a month on non-scheduled tasks leads to a month delay in completion date.
Surprise, surprise, dicking around for a month on non-scheduled tasks has led to a month delay in our projected completion date.

So I’m going to take this update to thank striking fast food workers for hastening the rise of humanity’s robot masters. I don’t know what roll a burger making robot will have in the glorious, metallic future though. Once humanity is gone there won’t be much call for burgers since everyone knows that robots use alcohol to fuel their mighty power cells. But I’m sure they will none-the-less make a valuable contribution to robo society.

Of course the date that machines will supplant meat-bag meat flippers is still underdetermined since Zerohedge’s commentary is actually just regurgitating a year old Business Insider article. Or (maybe) they used the wayback machine to view an old version of Momentum Machine’s website.

The current version of Momentum Machines website is a little thin on the news and details regarding their harbinger of the revolution (the last salient site update was in 2013). After more than three years of operation I’d expect some video or photographs of a prototype but, then again, if I was building Skynet in a San Francisco garage I would have an overly cheery website that was scant on details too.

Stoned in Space November

Since we got the all important promotional-cover image out of the way in September, we spent the better part of October actually working on Stoned in Space, and we made enough progress to have screen shots! Unfortunately Rho_bot has been less productive at graphics than I was at code (something about real life and an actual job was mentioned. Sounded pretty fishy to me), so we still have plenty of filler graphics and preliminary layouts.  While many of the details of the game continue to be shrouded from us some details have become clear.  Players will be able to choose a weapon, shield, and special ability for their ship.

ship-config screen

Rho_bot, Roid_0 is calling out to you  for real artwork.
Rho_bot, Roid_0 is calling out to you for real artwork.

While it still contains some filler graphics we’re comfortable with the layout of the game screen although we are discussing adding another control.


 

Schedule Update

 

Project has a 25% chance of completion on or before the date represented by the blue line and a 75% chance of completion by the red line. So we're currently looking at something Februaryish
Project has a 25% chance of completion on or before the date represented by the blue line and a 75% chance of completion by the red line. So we’re currently looking at something Februaryish

 

After some initial volatility the schedule seems to have settled on some time in February for a completion date. Since most of the buffer has been allocated we’ll see if that holds up for another month.