Java Logging

Hi,

Is there a way to use the java.util.logging class to create custom xml logs?

Here is a typical output I would like to see:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE log SYSTEM "logger.dtd">

<log>

<record>

<date>2000-08-23 19:21:05</date>

<millis>967083665789</millis><-- GET RID OF THIS

<sequence>1256</sequence>

<logger>kgh.test.fred</logger>

<level>INFO</level>

<class>kgh.test.XMLTest</class>

<method>writeLog</method>

<thread>10</thread>

<message>Hello world!</message>

<customTAG1>my custom tag</customTAG1>

<customTAG2>my custom tag</customTAG2>

<customTAG3>my custom tag</customTAG3>

</record>

</log>

Thanks

[977 byte] By [bce_developera] at [2007-11-26 23:53:42]
# 1
May I ask why? According to the DTD, the millis element is obligatory.
quittea at 2007-7-11 15:34:57 > top of Java-index,Java Essentials,Java Programming...
# 2

I didn't realize it was required. That's fine, I can leave that in. But I still would like to add my own elements:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE log SYSTEM "logger.dtd">

<log>

<record>

<date>2000-08-23 19:21:05</date>

<millis>967083665789</millis>

<sequence>1256</sequence>

<logger>kgh.test.fred</logger>

<level>INFO</level>

<class>kgh.test.XMLTest</class>

<method>writeLog</method>

<thread>10</thread>

<message>Hello world!</message>

<customTAG1>my custom tag</customTAG1>

<customTAG2>my custom tag</customTAG2>

<customTAG3>my custom tag</customTAG3>

</record>

</log>

Is it possible?

bce_developera at 2007-7-11 15:34:57 > top of Java-index,Java Essentials,Java Programming...
# 3
I don't know, I always use log4j. But I would first try writing a subclass of XMLFormatter (override the format() method) and make the logger use that.
DrClapa at 2007-7-11 15:34:57 > top of Java-index,Java Essentials,Java Programming...
# 4
How could I perform this using Log4j ?
bce_developera at 2007-7-11 15:34:57 > top of Java-index,Java Essentials,Java Programming...
# 5
> How could I perform this using Log4j ?I have no idea. Why do you ask?
DrClapa at 2007-7-11 15:34:57 > top of Java-index,Java Essentials,Java Programming...