Google App Engine uses java.util.logging.Logger (JUL) for all logging. Thus to log anything (and then subsequently retrieve it via the LogService), you just log like you normally do with JUL:
private Logger logger = Logger.getLogger(this.class.getName());
// ...
public void doWhatever() {
logger.info("This will be logged.");
}
But if you read over the GAE tutorials/guides for their various service APIs (Memcache, Mail, Datastore, etc.), they all reiterate that you should always code for the possibility that one of their services are down. GAE even provides a CapabilitiesService that you can check before calling any service method to see if that service is currently enabled or not.
So I ask: is there ever a chance that JUL logging operation will ever fail:
logger.info(“Can I ever fail and not get logged?”);
If not, why? And if so, what can I do to “failover” in the case that JUL has choked? Thanks in advance.
I’ve ran into this same problem, and yes the logging service can fail without errors. The best you’re going to get (until GAE improves the logging service API), is to cron a job to wake up, say, every minute, and perform a
logger.info(...).Then run a
LoggingService#fetchLogs(...), filtered to only retrieve theAppLogLinecontaining the most recent logger call, and check to make sure you can retrieve it. If you can’t, then thelogger.info(...)failed, and you can have your app react however you like.I always expose a secure servlet on my GAE apps that pings the Capabilities Service and asks for a status check on each service. If the service is disabled or down for maintenance, I have an external monitor (that checks this URL every 5 mins) send me a text message. You can tie this “log checking” cron job into that kind of a service check.