On 7/17/07, Townson, Chris <[EMAIL PROTECTED]> wrote:
thanks, Will - I should probably go back and have another look at logging in my 
default Velocity setup.

fyi/btw: I am using 1.5 ... I last thought about logging when I upgraded. I was thinking 
"ah ha! this might fix that logging annoyance too!" - but it didn't :( ... so I 
left it alone for some rainy day.

what logging annoyance?  i've put in a fair bit of effort to clean up
the logging stuff. (again, sorry for my gross oversight of the old
"category" stuff in the logging section of the developer's guide.  if
there's more that can be done to simplify or clarify it (short of
using static logging internally), i'd be interested.  but i'm not
quite sure what the annoyance here is?

for the record, my default setup (dealing purely with tomcat webapps here) 
looks like this:

/WEB-INF
    |- /classes
          |- log4j.properties
    |- /lib
          |- ... velocity jars, commons jars, log4j jar, my jars etc ...
    |- toolbox.xml
    |- velocity.properties
       (specifying log4j logchute with runtime.log.logsystem.class)

do you point the log4j logchute to an existing logger? or leave it to
use the default?

    |- web.xml
       (using VelocityViewServlet mapped to *.html and *.vm)

... and so on. All totally standard and basic - but my log4j.properties is not 
used by
Velocity - but it _is_ used by Spring, which I use a lot, and any Commons 
Logging stuff I
use in my own code.

i'm not sure what you mean by "used by" here.  Velocity shunts all log
messages through the LogChute of choice.  if you tell it to use the
Log4jLogChute, it will either use a specific logger that you tell it
to use, or else it will create a default one.  where in this should we
be looking at a log4j.properties file? and to what end?

In fact, velocity is the only library I work with regularly for which this 
setup does not work
... which has always struck me as curious - but not curious enough that I have 
felt the
need to investigate and fix :D

C

> -----Original Message-----
> From: Will Glass-Husain [mailto:[EMAIL PROTECTED]
> Sent: 17 July 2007 14:56
> To: Velocity Users List
> Subject: Re: Can't make it log with log4j
>
> Joe/Chris--
>
> I use log4j in some of my apps, haven't had much trouble.
>
> Are you using Velocity 1.5?  Velocity's logging behavior was
> cleaned up
> substantially in the last release.  The
> "velocity.log" file is generated by the Avalon logkit, it
> shouldn't appear
> if you use Log4J.  Try removing "logkit.jar" from your classpath.
>
> One thing that causes problems is when random third-party
> libraries (cough -
> Axis2!) include a log4j.properties in their jar file.  Since
> log4j looks for
> the first log4j.properties it can find, if it hits some other
> library's file
> first it will ignore the log4j for your main app.
>
> I solve this by either (A) manually initializing log4j in my
> app startup
> with the correct properties file or (B) just being careful
> that there's only
> one log4j.properties in my classpath.
>
> WILL
>
> On 7/17/07, Townson, Chris <[EMAIL PROTECTED]> wrote:
> >
> > Hi Malcolm and Joe,
> >
> > I have to echo Joe's comments: Velocity's behaviour with
> log4j and Commons
> > Logging is one of the things I find I find most irritating
> in general
> > development terms (as everything else is so nice and simple
> and works fine
> > on the whole).
> >
> > I have _never_ been able to get logging to work satisfactorily
> > (admittedly, I gave up a while back and haven't tried again).
> >
> > Why a log4j.xml rather than properties?
> >
> > I always have log4j.properties at the root of the
> classpath: this gets
> > routinely ignored by Velocity, I'm sorry to say.
> >
> > It's not too big a deal to me and can accept a separate log
> file, but it
> > would be good if (like many other apps/frameworks; e.g.
> Spring) Velocity
> > just transparently picked-up my log4j config and output to
> the same file as
> > everything else.
> >
> > Chris
> >
> > > -----Original Message-----
> > > From: Malcolm Edgar [mailto:[EMAIL PROTECTED]
> > > Sent: 17 July 2007 14:13
> > > To: Velocity Users List
> > > Subject: Re: Can't make it log with log4j
> > >
> > > I would recommend using the log4j.xml configuration file,
> and put it
> > > somewhere up high in your class path.
> > >
> > > regards Malcolm Edgar
> > >
> > > On 7/17/07, Joe Kramer <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hello,
> > > >
> > > > I have hard time taming velocity log output.
> > > > My webapp uses log4j globally.
> > > > velocity.properties has the following:
> > > >   runtime.log.logsystem.class =
> > > > org.apache.velocity.runtime.log.Log4JLogChute
> > > >   runtime.log.logsystem.log4j.category=velocity
> > > >
> > > > log4j.properties:
> > > >   log4j.rootCategory=INFO, LOGFILE
> > > >   log4j.appender.LOGFILE=org.apache.log4j.FileAppender
> > > >   ...
> > > >   log4j.velocity=WARN
> > > >   log4j.org.apache.velocity=WARN
> > > >
> > > > Regardless of above configuration, velocity creates it's own
> > > > velocity.log and logs with some default settings.
> > > > What is more strange, every message is velocity.log is
> > > repeated 5 to 6
> > > > times!
> > > >
> > > > Can anyone point me the best practice to configure velocity
> > > with log4j ?
> > > >
> > > > Thanks.
> > > >

********************************************************************************
DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
not the original intended recipient. If you have received this e-mail in error
please inform the sender and delete it from your mailbox or any other storage
mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
liability for any statements made which are clearly the sender's own and not
expressly made on behalf of Macmillan Publishers Limited or one of its agents.
Please note that neither Macmillan Publishers Limited nor any of its agents
accept any responsibility for viruses that may be contained in this e-mail or
its attachments and it is your responsibility to scan the e-mail and
attachments (if any). No contracts may be concluded on behalf of Macmillan
Publishers Limited or its agents by means of e-mail communication. Macmillan
Publishers Limited Registered in England and Wales with registered number 785998
Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS
********************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to