You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Kerry Todyruik <ke...@todyruik.com> on 2001/12/06 00:11:08 UTC

LogKit Date/Time Format

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


Regards,
Kerry Todyruik

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


Re: LogKit Date/Time Format

Posted by Peter Donald <pe...@apache.org>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>