Hi John,
I'm not very experienced with torque but I started the same way as you did.
To setup torque with the init()-method in a servlet seems to me a good way
as
well.
When I started I wanted to use the newest version of log4j, say 1.2, but
torque was shipped with 1.1.3. and I didn't get it running with 1.2
So I use log4j 1.1.3. throughout the whole of my application.
The story with the initialization of the logging system of torque was a
problem
for me too but then I realized, after looking into the source of
org.apache.torque.Torque.java,
that if you initialize the logging stuff before you initialize torque than
it's working as you want.
So I have another Servlet (or ServletContextListener) setting up the logging
stuff for my web-application.
In there I initialize the torque logging part and when you call the
Torque.init()-method it is
recognizing that logging is configured (Torque.isLoggingConfigured()) and
there's nothing left
for Torque to initialize the torque-logging.

The 'logs' directory is mentioned in the source code :
org.apache.torque.Torque.java:

        protected static void configureLogging()
        {
            if (isLoggingConfigured() == false)
            {
                // Get the applicationRoot for use in the log4j
                // properties.
                String applicationRoot =
getConfiguration().getString("torque.applicationRoot", ".");

                //!! Need a configurable log directory.
                File logsDir = new File(applicationRoot, "logs");

                if (logsDir.exists() == false)
                {
                    if (logsDir.mkdirs() == false)
                    {
                        System.err.println("Cannot create logs directory!");
                    }
                }

So you have to setup the applicationRoot correctly and then it probably
works. I don't know why it's
implemented like this but as I said I'm not very experienced with that.
Either way you can have a workaround when you initiliaze the logging system
before you initialize torque (Call Torque.init()).
If you find out how to initialize torque with a higher version of log4j
1.1.3. it would be good if you post it.

Ralf



----- Original Message -----
From: "katre" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 11, 2002 3:06 PM
Subject: Torque, Struts, and Logging

Hello all,

I recently started writing a (fairly simple) webapplication using
Struts, but I needed something to handle object persistence from my DB.
I thought for a bit about writing my own code to do this, then realized
that someone must have done it already. :) So I found Torque.

Setting up Torque, while difficult (I tried running through the tutorial
with no success.  Is it written for the current (3.0-b3) version?),
wasn't too bad.  I managed to integrate it with my existing build
system, to auto-generate the SQL to create the database and schema, and
even to roll it into a WAR for easy deployment.

I then wrote a small command-line test app, which worked fine.  But when
I tried to integrate Torque with my webapp, I had several problems.
First was that I wasn't sure how to initialize Torque inside the webapp,
given that the Torque.properties file was also inside the webapp.  After
a busy day of coding, I figured out how to load the properties file as a
resource (via the classloader), convert that to a
PropertiesConfiguration, and initialize Torque with that.  I was on my
way!

Except.  I cannot figure out what to do with the logs Torque is trying
to open.  Torque initialization is trying to open the logs, and Tomcat
is reporting various types of AccessControlException.  The odd part is
that I updated the properties file to write all the logs to
/var/log/webapps/, but the exception is coming from an attempt to acces
'./logs', which isn't mentioned in the properties file anywhere!  I also
noticed that whenever I run the Torque build scripts (from ant, from the
commandline) a file named 'velocity.log' is created in the current
directory.

How can I reconfigure Torque to put the logs in the proper place?  Am I
doing something incredibly stupid?  Does anyone have any advice for my
silly little webapp?

Thanks for your help,
John Cater
[EMAIL PROTECTED]




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

Reply via email to