On Thu, 6 Dec 2001 10:11, Kerry Todyruik wrote:
> Is there a way of formatting the date/time field in LogKit so that it
> outputs in a human readable format like Log4J does?
>
> %d{yyyy-MM-dd HH:mm:ss}
>
> 2001-12-04 12:00:54 INFO  [Category] - Message Text here

Unfortunately you have to subclass a Formatter such as 

class MyFormatter extends PatternFormatter
{
    MyFormatter( String pattern )
    {
      super( pattern );
    }

    protected String getTime( final long time, final String format )
    {
        //Format the date however you want here
        return (new Date( time )).toString();
    }
}

Alternatively you could modify the PatternFormatter class so that when you 
pass an ancilliary parameter in formatting string that it formats according 
to that. 

So for instance if you specify the pattern "%5.5{time:yyyy-MM-dd HH:mm:ss}" 
then getTime() will be called with the second parameter specified as  
"yyyy-MM-dd HH:mm:ss"

You could use this information to format the time appropriately ;)

-- 
Cheers,

Pete

-----------------------------------------------------
First, we shape our tools, thereafter, they shape us.
-----------------------------------------------------


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

Reply via email to