Re: Concurrent, persistent background process for a J2EE container
Mark Space <firstname.lastname@example.org> wrote in
I think your boss is correct. The Java LogManager is pretty robust.
I'd definitely try that first, and only abandon it when it was proven
it couldn't work. The LogManager is pretty sophisticated, it'll even
rotate your logs for you.
Writing logs to a database... why? The logs should be simple, so that
they are present even when things don't work. How are you going to
debug database problems when the logs didn't get written because the
database was supposed to be hold the logs in the first place? This
seems circular, and unnecessarily complex. Even baroque.
If I got an app that wrote logs to a database, I think I'd curse your
name. Just saying....
Toying with java.util.logger
Logger formats and logs a LogRecord object.
I'm trying to extend it for my purposes, to get that structure in it.
Seems Logger does not call format() for my extended object.
The code to toy with is here. The missing error is in the testUrl method,
which is part of my another "toy". It is quaranteed to throw an error,
and get the message logged. But no log entry there. format() will not be
import java.net.* ;
public class Main extends Formatter
public String format(LogRecord record)
if (record instanceof Something)
Something some = (Something) record ;
return some.toString() +
return "####" + record.getMessage() + "####" +
public class Something extends LogRecord
private String value ;
public Something(String value)
super(Level.ALL, value) ;
this.value = value ;
public String toString()
return value ;
public static void setup()
Logger log = Logger.getLogger("foobar");
while (log.getParent() != null)
log = log.getParent();
new URL("ldap://localhost:389") ;
catch (Exception ex)
Something some = new Something(ex.getMessage()) ;
public static void main(String args)
Main blah = new Main() ;
Logger logger1 = Logger.getLogger("test");
logger1.info("This is a test");
Logger logger2 = Logger.getLogger("test.test");
logger2.info("This is also a test");