You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Peter Donald <do...@mad.scientist.com> on 2000/09/14 16:50:08 UTC
Re: cvs commit:
jakarta-velocity/src/java/org/apache/velocity/log Log.java
LogHandle.java LogImpl.java Test.java
At 09:25 14/9/00 -0400, you wrote:
>> Well there is already a logging toolkit in Avalon code base that is
>> basically equivelent to log4j but better designed - thou I am biased as I
>> am writer :P.
>
>+1
>
>Well, heck, then. Problem solved. ;)
>
>I think Jason'n'I both decided that log4j was somewhat over-engineered.
>But if the ASF already has something in-use Elsewhere, I could go with
>using it in More Projects. Commonality is Good.
>
>What's the process for sharing code betwixt projects? Should Logger
>stuff get carved out into a .jar for inclusion? I'd hate to just
>copy/paste files around, as it'd make staying in-sync a tad more
>difficult, eh?
when you build Avalon it builds it into a seperate jar (log.jar) which you
can nab. Avalon is going to have a release Real Soon Now (tm) :P so you
could even get it from that.
Eventually I plan to make a proposal for another Apache project - but too
lazy to do that atm :P. Thers another logging toolkit that may be released
under APL at which point then will try and get it going as seperate project
- until then it is probably best just to nab the jar ???
>D'ya have Logger-For-Newbies docs somewhere handy?
Well not exactly - I used but it got lost :P. Basically for clients of
logging system (ie those who want to use it) you just do something like
import org.apache.log.LogKit;
import org.apache.log.Logger;
public class Blah
{
protected final static boolean LOG = true;
protected final static boolean DEBUG = LOG
&& false;
protected final static Logger LOGGER =
( LOG ) ? LogKit.getLoggerFor( "MyCategory" ) : null;
public void someMethod()
{
if( LOG ) LOGGER.warn("MyWarning", myException );
if( LOG ) LOGGER.error("this does not compute", myException );
if( LOG ) LOGGER.info("infomational messages are here" );
if( LOG ) LOGGER.debug("debug info goes here");
}
Unfortunately for those who initially setup the server system I removed all
auto-configuration stuff right before I put it in CVS because it was an
ugly hack :P. So the best place to look I guess is in in the configuration
file for Avalon (or specifically chunk I paste below) and the code that
loads configuration data (specifically the file at
http://www.working-dogs.com/cvsweb/index.cgi/framework/src/java/org/apache/a
valon/blocks/logmanager/DefaultLogManager.java).
Once the initial configuration is set up it is easy as pie - but that first
bit is a little annoying. I really should fix that :P
----------------------------------------------------------------------------
Configuration file chunk.
----------------------------------------------------------------------------
<global-priority>DEBUG</global-priority>
<category name="core_blocks" target="core_blocks" priority="DEBUG" />
<category name="Kernel" target="kernel" priority="DEBUG" />
<category name="Schedular" target="default" priority="WARN" />
<target name="default" class="org.apache.log.output.FileOutputLogTarget">
<param name="filename" value="../logs/default.log" />
</target>
<target name="kernel" class="org.apache.log.output.FileOutputLogTarget">
<param name="filename" value="../logs/kernel.log" />
<param name="format" value="[%.14{category}]: %{message}\n" />
</target>
<target name="core_blocks" class="org.apache.log.output.FileOutputLogTarget">
<param name="filename" value="../logs/core_blocks.log" />
<param name="format" value="[%.14{category}]: %{message}\n" />
</target>
----------------------------------------------------------------------------
Cheers,
Pete
*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power." |
| -Abraham Lincoln |
*------------------------------------------------------*