You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Thomas Tuft Muller <tt...@online.no> on 2001/12/11 11:25:46 UTC

Log4j xml config evaluation

Hi,

I'm using Log4j and Ant, and since the log4j configuration files in our
system is starting to get quite chunky, it would be nice to evaulate the
log4j files during the build process. Does ant have any tasks for doing
this, or if not; what's the best way to evaulate a log4j.xml file?

Regards,

--

Thomas



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Log4j xml config evaluation

Posted by Thomas Tuft Muller <tt...@online.no>.
| > I guess one way to do it is to configure a new Java process with the
| > DOMConfigurator/logfj.xml and check if any errors are submitted to std
| err.
|
| Does the DOMConfigurator throw exceptions?

Unfortunately not (except javax.xml.parsers.FactoryConfigurationError, which
is a subclass of java.lang.Error).

|  If so, you could just wrap it
| inside a JUnit test case and use the <junit> task to deal with it
| (haltonfailure="true" even!).  Even without exceptions, if there is
| something you can check for perhaps a JUnit test is still a good
| thing.  Or
| a custom Ant task (which should live in the Log4j codebase, I'd
| think) would
| be even more easily re-usable by others.

I agree. An ant task is definately the way to go, but my time is very
limited at the mo, and I'm already familiar with JUnit, so I think that's
the best tip for now.

BTW, it seems like xmlvalidator always look for the dtd in the directory
where it finds the XML file. What if I use a FileSet? Can I point to a
common dtd for all the files?

The log4j XML files start with:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

I'm by no means an XML expert, but doesn't the second statement indicate
that log4j.dtd should be searched for in the CLASSPATH?

--

Thomas




*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Log4j xml config evaluation

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
----- Original Message -----
From: "Thomas Tuft Muller" <tt...@online.no>

> I guess one way to do it is to configure a new Java process with the
> DOMConfigurator/logfj.xml and check if any errors are submitted to std
err.

Does the DOMConfigurator throw exceptions?  If so, you could just wrap it
inside a JUnit test case and use the <junit> task to deal with it
(haltonfailure="true" even!).  Even without exceptions, if there is
something you can check for perhaps a JUnit test is still a good thing.  Or
a custom Ant task (which should live in the Log4j codebase, I'd think) would
be even more easily re-usable by others.

    Erik



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Log4j xml config evaluation

Posted by Thomas Tuft Muller <tt...@online.no>.
| The optional <xmlvalidate> task will validate XML files against DTD's.

Thanks!

| As for checking something more detailed like appenders exist for the
| categories defined - you're probably on your own there, unless Log4j has
| some built-in API to verify a configuration file.

I guess one way to do it is to configure a new Java process with the
DOMConfigurator/logfj.xml and check if any errors are submitted to std err.

Again, thanx.

--

Thomas














*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Log4j xml config evaluation

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
The optional <xmlvalidate> task will validate XML files against DTD's.

As for checking something more detailed like appenders exist for the
categories defined - you're probably on your own there, unless Log4j has
some built-in API to verify a configuration file.

    Erik


----- Original Message -----
From: "Thomas Tuft Muller" <tt...@online.no>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Tuesday, December 11, 2001 6:12 AM
Subject: RE: Log4j xml config evaluation


> Sorry, I didn't emphasize that I meant log4j *XML* files. I'd define
> evaulating a log4j XML file as 1) determing that it's a valid XML file
> according to the log4j dtd, and 2) when applied it will result in a valid
> log4j configuration (i.e. all appenders defined for the categories exist
> etc. I guess part 2 of my definition applies to a log4j property file as
> well).
>
> --
>
> Thomas
>
>
> | -----Original Message-----
> | From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com]
> | Sent: 11 December 2001 11:04
> | To: Ant Users List; ttm@online.no
> | Subject: Re: Log4j xml config evaluation
> |
> |
> | What do you mean by "evaluate"?
> |
> | A Log4j configuration file is simply a properties file, so you
> | could load it
> | into Ant properties using <property file="..."/> or manipulate it using
> | <propertyfile>
> |
> | But there is nothing specific to do anything special with Log4j
> | configuration files beyond that.
> |
> |     Erik
> |
> | ----- Original Message -----
> | From: "Thomas Tuft Muller" <tt...@online.no>
> | To: <lo...@jakarta.apache.org>; <an...@jakarta.apache.org>
> | Sent: Tuesday, December 11, 2001 5:25 AM
> | Subject: Log4j xml config evaluation
> |
> |
> | > Hi,
> | >
> | > I'm using Log4j and Ant, and since the log4j configuration files in
our
> | > system is starting to get quite chunky, it would be nice to evaulate
the
> | > log4j files during the build process. Does ant have any tasks for
doing
> | > this, or if not; what's the best way to evaulate a log4j.xml file?
> | >
> | > Regards,
> | >
> | > --
> | >
> | > Thomas
> | >
> | >
> | >
> | >
> |
*************************************************************************
> | > Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights
> | reserved.
> | > Confidential. No liability whatsoever is accepted for any loss or
damage
> | > suffered as a result of accessing this message or any attachments.
> | >
> | > --
> | > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
>
> *************************************************************************
> Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved.
> Confidential. No liability whatsoever is accepted for any loss or damage
> suffered as a result of accessing this message or any attachments.
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Log4j xml config evaluation

Posted by Stefan Bodewig <bo...@apache.org>.
I don't use Log4J myself, so I can't comment on your second point, but

On Tue, 11 Dec 2001, Thomas Tuft Muller <tt...@online.no> wrote:

> 1) determing that it's a valid XML file according to the log4j dtd,

See the optional <xmlvalidate> task.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Log4j xml config evaluation

Posted by Thomas Tuft Muller <tt...@online.no>.
Sorry, I didn't emphasize that I meant log4j *XML* files. I'd define
evaulating a log4j XML file as 1) determing that it's a valid XML file
according to the log4j dtd, and 2) when applied it will result in a valid
log4j configuration (i.e. all appenders defined for the categories exist
etc. I guess part 2 of my definition applies to a log4j property file as
well).

--

Thomas


| -----Original Message-----
| From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com]
| Sent: 11 December 2001 11:04
| To: Ant Users List; ttm@online.no
| Subject: Re: Log4j xml config evaluation
|
|
| What do you mean by "evaluate"?
|
| A Log4j configuration file is simply a properties file, so you
| could load it
| into Ant properties using <property file="..."/> or manipulate it using
| <propertyfile>
|
| But there is nothing specific to do anything special with Log4j
| configuration files beyond that.
|
|     Erik
|
| ----- Original Message -----
| From: "Thomas Tuft Muller" <tt...@online.no>
| To: <lo...@jakarta.apache.org>; <an...@jakarta.apache.org>
| Sent: Tuesday, December 11, 2001 5:25 AM
| Subject: Log4j xml config evaluation
|
|
| > Hi,
| >
| > I'm using Log4j and Ant, and since the log4j configuration files in our
| > system is starting to get quite chunky, it would be nice to evaulate the
| > log4j files during the build process. Does ant have any tasks for doing
| > this, or if not; what's the best way to evaulate a log4j.xml file?
| >
| > Regards,
| >
| > --
| >
| > Thomas
| >
| >
| >
| >
| *************************************************************************
| > Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights
| reserved.
| > Confidential. No liability whatsoever is accepted for any loss or damage
| > suffered as a result of accessing this message or any attachments.
| >
| > --
| > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>




*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Log4j xml config evaluation

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
What do you mean by "evaluate"?

A Log4j configuration file is simply a properties file, so you could load it
into Ant properties using <property file="..."/> or manipulate it using
<propertyfile>

But there is nothing specific to do anything special with Log4j
configuration files beyond that.

    Erik

----- Original Message -----
From: "Thomas Tuft Muller" <tt...@online.no>
To: <lo...@jakarta.apache.org>; <an...@jakarta.apache.org>
Sent: Tuesday, December 11, 2001 5:25 AM
Subject: Log4j xml config evaluation


> Hi,
>
> I'm using Log4j and Ant, and since the log4j configuration files in our
> system is starting to get quite chunky, it would be nice to evaulate the
> log4j files during the build process. Does ant have any tasks for doing
> this, or if not; what's the best way to evaulate a log4j.xml file?
>
> Regards,
>
> --
>
> Thomas
>
>
>
> *************************************************************************
> Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved.
> Confidential. No liability whatsoever is accepted for any loss or damage
> suffered as a result of accessing this message or any attachments.
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>