You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by bob mcwhirter <bo...@werken.com> on 2002/03/24 02:20:49 UTC

Log4JLogSystem...

Howdy folks...

Was wondering who, if anyone, uses the Log4JLogSystem.

My application already has log4j configured, with log4j.properties doing
the things I want it to do.  I'm attempting to use the Log4JLogSystem,
but it seems to insist on appending its logs to its own logfile, and
doesn't send them to my normal appender.  Plus, there seems to be no
way of setting the Category that Velocity will use.

I'm on the verge of writing my own Log4JLogSystem to work more intuitively
and friendly with an existing log4j system an application might already
have.  

Any comments?  Someone want to tell me that I'm simply using velocity's
Log4JLogSystem the WrongWay(tm)?

	thanks,

	-bob


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


Re: Log4JLogSystem...

Posted by Barbara Baughman <ba...@utdallas.edu>.
I am using Velocity 1.1-rc2 and Log4J 1.1.3.  This may or may not be
helpful, but it's before the new handling of Log4J logging. 

The velocity.properties file has:

runtime.log=/WEB-INF/logs/velocity.log
runtime.log.logsystem.class=org.apache.velocity.runtime.log.Log4JLogSystem
runtime.log.logsystem.log4j.pattern=%d - %m%n
runtime.log.logsystem.log4j.file.size=10000
runtime.log.logsystem.log4j.file.backups=1 

In the MainController (relevant code only):
import org.apache.log4j.PropertyConfigurator;

public class MainController extends VelocityServlet {
    protected Properties loadConfiguration(ServletConfig config )
            throws IOException, FileNotFoundException {
        /* get properties file and load it from web application root */
            
        String propsFile = config.getInitParameter(INIT_PROPS_KEY);
        Properties p = new Properties();
     
        if ( propsFile != null ) {
            String realPath = context.getRealPath(propsFile);
            if ( realPath != null ) {
                propsFile = realPath;
            }
            p.load( new FileInputStream(propsFile) );
            PropertyConfigurator.configure(propsFile);
        }
    }
}

Barbara Baughman
X2157

On Sat, 23 Mar 2002, bob mcwhirter wrote:

> 
> Howdy folks...
> 
> Was wondering who, if anyone, uses the Log4JLogSystem.
> 
> My application already has log4j configured, with log4j.properties doing
> the things I want it to do.  I'm attempting to use the Log4JLogSystem,
> but it seems to insist on appending its logs to its own logfile, and
> doesn't send them to my normal appender.  Plus, there seems to be no
> way of setting the Category that Velocity will use.
> 
> I'm on the verge of writing my own Log4JLogSystem to work more intuitively
> and friendly with an existing log4j system an application might already
> have.  
> 
> Any comments?  Someone want to tell me that I'm simply using velocity's
> Log4JLogSystem the WrongWay(tm)?
> 
> 	thanks,
> 
> 	-bob
> 
> 
> --
> 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: Log4JLogSystem...

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/23/02 9:15 PM, "bob mcwhirter" <bo...@werken.com> wrote:

>>> Thanks for the pointer.
>> 
>> That is what you want, right? :)
> 
> Yah, I think so.  Have only looked at the Javadoc, not the sources
> yet.  One question:  how do I set the Category for it to use?  Can't
> seem to find a setCategory(...) method.  I'm assuming it greps some
> property from the runtime, no?
> 

Si' -

VelocityEngine ve = new VelocityEngine();

ve.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
   "org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );

ve.setProperty("runtime.log.logsystem.log4j.category", <your_categoryname>);

ve.init();

geir
-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
POC lives!


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


Re: Log4JLogSystem...

Posted by bob mcwhirter <bo...@werken.com>.
> > Thanks for the pointer.
> 
> That is what you want, right? :)

Yah, I think so.  Have only looked at the Javadoc, not the sources
yet.  One question:  how do I set the Category for it to use?  Can't
seem to find a setCategory(...) method.  I'm assuming it greps some
property from the runtime, no?

	-bob


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


Re: Log4JLogSystem...

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/23/02 8:57 PM, "bob mcwhirter" <bo...@werken.com> wrote:

>> The Log4JLogSystem is deprecated.
>> 
>> Use the SimpleLog4JLogSystem.  You set up log4j, and then tell velocity what
>> category to use...
> 
> Hokie dokie.  That's in the 1.3 pre-release only, I'm assuming?  I'm just
> working with 1.2 at this moment, which doesn't include it.  Will upgrade
> soon, though.
> 
> Thanks for the pointer.

That is what you want, right? :)

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
POC lives!


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


Re: Log4JLogSystem...

Posted by bob mcwhirter <bo...@werken.com>.
> The Log4JLogSystem is deprecated.
> 
> Use the SimpleLog4JLogSystem.  You set up log4j, and then tell velocity what
> category to use...

Hokie dokie.  That's in the 1.3 pre-release only, I'm assuming?  I'm just
working with 1.2 at this moment, which doesn't include it.  Will upgrade
soon, though.

Thanks for the pointer.

	-bob


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


Re: Log4JLogSystem...

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/23/02 8:20 PM, "bob mcwhirter" <bo...@werken.com> wrote:

> 
> Howdy folks...
> 
> Was wondering who, if anyone, uses the Log4JLogSystem.
> 
> My application already has log4j configured, with log4j.properties doing
> the things I want it to do.  I'm attempting to use the Log4JLogSystem,
> but it seems to insist on appending its logs to its own logfile, and
> doesn't send them to my normal appender.  Plus, there seems to be no
> way of setting the Category that Velocity will use.
> 
> I'm on the verge of writing my own Log4JLogSystem to work more intuitively
> and friendly with an existing log4j system an application might already
> have.  
> 
> Any comments?  Someone want to tell me that I'm simply using velocity's
> Log4JLogSystem the WrongWay(tm)?

The Log4JLogSystem is deprecated.

Use the SimpleLog4JLogSystem.  You set up log4j, and then tell velocity what
category to use...

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"Now what do we do?"


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