velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: Problems using logging in Velocity 1.6.2
Date Mon, 24 Aug 2009 21:46:22 GMT
Hi Matthias,

Believe your eyes.  The cues you need are in the source of the
JdkLogChute.java file, lines 81-96.  debug->FINE, trace->FINEST,
warn->WARNING, error->SEVERE, info->INFO.

And yeah, the overwhelming majority of Velocity log output happens at
the debug/FINE level.  You would only get a SEVERE if there were an
error and only in very unlikely circumstances will you get a WARNING
message.   There are certainly a few trace/FINEST messages out there,
but not many.   Most messages are debug/FINE because they're there for
debugging.  INFO is not really a relevant level for Velocity.  The
presence of a myriad of log levels doesn't necessitate the use of them
all.  Velocity is a utility library, not a framework and certainly not
an application.  Logging is pretty much just for debugging or error
reporting.  There is little other data that needs logging in Velocity,
and not much that users really need to ever see.

It's my hope/plan to change things in the 2.x branch such that level
is not the primary categorization for log messages.  For Velocity,
it's more important to know what function a message relates to.  I'm
envisioning developers using it like getLog().resources(message) and
getLog().reflection(message, level)  or maybe even
getLog().users(message) to output things users need to see.  Of
course, i've been swamped with other work and haven't gotten to work
on this yet, though it's one of the things i'm more excited about
doing.

On Sun, Aug 23, 2009 at 1:07 AM, Dr. Matthias Laux<matthias.laux@web.de> wrote:
> (aopolgies if this should appear twice - I don't
> see my first email on the mailing list archive so
> I gather the mail may not have made it)
>
>
>
> Hi,
>
> I'm lost getting Velocity logging to work the way I need it.
>
> In the past I used the Velocity directly such as
>
> Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
> templateDir);
> Velocity.init();
>
> and got the expected output in the velocity.log file.
>
> Now I moved to using VelocityEngine instead because I had some issues with
> the output
> in a long running server app which performed the same tasks over and over
> again (the
> velocity.log file would grow and I did not know how to get Velocity to start
> a new file
> for every processing run).
>
> Anyway. Now the new code started to look like this:
>
> engine = new VelocityEngine();
> engine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateDir);
> engine.init();
>
> and nothing happens other than an empty file "velocity.log" being created.
> Well.
>
> So I added a LogChute:
>
> engine = new VelocityEngine();
> engine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateDir);
> engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
> "org.apache.velocity.runtime.log.JdkLogChute");
> engine.init();
>
> because I'm using JDK logging in my app anyway. My own logging is based
> on a console handler with level INFO and a file handler with level FINE (at
> least right now).
>
> What happened now was that there was nothing related to Velocity on the
> console, and truckloads of FINE log entries in the file handler. That's not
> quite all of the expected results, but it's the best I got so far. As it
> seems,
> Velocity seems to pick up the settings of the JDK logging subsystem.
>
> It gets weird tho when I set the logging level for the file handler to INFO
> as
> well: all log entries to the file handler for the JdkLogChute are gone. The
> only
> way for me to understand these observations is that only log messages of
> level FINE are actually recorded. Even if I go to level FINEST and check out
> the log files afterwards, there's zillions of Velocity log entries, but all
> with level FINE. This works also for the java.util.logging.ConsoleHandler,
> i. e. setting the level to FINE there also gives me the log messages, but
> all of level FINE. In my original velocity.log there were - for the same set
> of
> data - "[error]" and "[debug]" entries which I would like to see again as
> corresponding log entries.
>
> Having only messages of level FINE can't be correct tho.
>
> When, for testing purposes, I add a manual log entry like this
>
> engine.getLog().info("Hello");
>
> right after the init(), it works on both console and file. So the loggers
> used inside Velocity also work correctly, but it seems that Velocity
> itself only creates log messages with level FINE - which I refuse to
> believe.
>
> I also tried the AvalonLogChute instead since that seems to be the
> default used in my previous implementation (velocity.log created
> by interacting with Velocity instead of VelocityEngine). Same result
> - an empty velocity.log file. Well, this is not too surprising since
> I presume that the AvalonLogChute is still the default - and I had
> not specified a LogChute in the first attempts.
>
> I'm kinda lost right now. I would like to be able to use JDK logging
> (since then I don't have to deal with different output files in analysis
> afterwards) and I would like to propagate the (configurable) log
> levels of my application to the Velocity logging.
>
> At the very least, I need a new velocity.log file to be created whenever
> my application starts a new iteration - whichever LogChute gives
> me that back. It does this effectively as listed above:
>
> Old version:
>
> Invoke
>
> Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
> templateDir);
> Velocity.init();
>
> -> results in all output being appended to one velocity.log file. This will
> be a file system capacity issue in the long run.
>
> New Version:
>
> engine = new VelocityEngine();
> engine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateDir);
> engine.init();
>
> -> results in an empty velocity.log. Not very helpful for finding problems.
>
> Any help would be very much appreciated. Studying the Velocity source
> code gave me some hints, but for now to no avail. Something must be
> wrong in the way I configure the VelocityEngine instance, I guess.
>
> Thanks,
> Matthias
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message