Steven--
Yes, it would be a performance hit to open and close the log each time you
wanted to log something; why not instead hold the FileOutputStream or
FileWriter reference as a member of the servlet? Open it in init(), close it
in destroy(), write to it wherever....
Alternatively, if you want a suite of servlets to all write to the same log,
create a "Log" class that's got a synchronized log() method, and have all
the servlets hold a reference to the same Log instance.... Either way,
you're now avoiding the hit (the twofold hit, actually--one to construct the
Java object, the other to go into native code to do the actual
file-open/close) on each log().
Ted Neward
Java Instructor, DevelopMentor ( http://www.develop.com )
http://www.javageeks.com/~tneward
-----Original Message-----
From: Danny Rubis <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, December 13, 1999 4:47 PM
Subject: Re: logging to text file
>Hey!
>
>Yeah. One could, if they already have a login servlet, just keep a Vector
of login
>information and write it out once in a while and also in the destroy(). No?
>
>Danny Rubis
>
>Steven Owens wrote:
>
>> > > > Steven Lau wrote:
>> > > > I'm doing some custom logging to a text file to make things easier
and
>> > > > cheaper than to logging to a database. The servlet would get the
header
>> > > > information, session Id and so on and attemps to log it to a file.
The
>> > > > problem I have is I don't know how to insert it to a file instead
of
>> > > > overwritting it. Instead of having multiple entries, it will open
the file
>> > > > and overwrite what's on it resulting in a file having only one log.
>>
>> Okay, this may seem like an odd question, but I've always been
>> overly careful about file IO, and I'm told java's file IO is pretty
>> slow to begin with. Opening and closing the file for each log message
>> seems extreme to me. Is this just my own neurosis or is it a
>> significant performance issue?
>>
>> Steven J. Owens
>> [EMAIL PROTECTED]
>> [EMAIL PROTECTED]
>>
>>
___________________________________________________________________________
>> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
>> of the message "signoff SERVLET-INTEREST".
>>
>> Archives: http://archives.java.sun.com/archives/servlet-interest.html
>> Resources: http://java.sun.com/products/servlet/external-resources.html
>> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html