RE: [PATCH] log output can get messed up with org.apache.catalina.logger.FileLogger

2002-02-20 Thread Kevin Seguin

> 
> Another way to fix this would be to use String concatenation. 
>  The question
> is, which is more expensive, the synchronization or the 
> String concatenation?
> 

yeah, that occurred to me too... anybody have an answer?

> This is how the code would be with String concatenation:
> 
>  // Log this message, timestamped if necessary
>  if (writer != null) {
>  if (timestamp) {
>  writer.println(tsString + " " + msg);
>  } else {
> writer.println(msg);
>  }
>  }
> 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: [PATCH] log output can get messed up with org.apache.catalina.logger.FileLogger

2002-02-19 Thread Remy Maucherat

> attached is a patch with one possible solution  - i could commit this, but
i generally
> don't commit on tomcat4, so i'd like some +1's before committing :)

+1, but you don't need my permission (I'd complain if I don't like a patch).
If you can, commit the patch on both branches.

Thanks,
Remy



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




[PATCH] log output can get messed up with org.apache.catalina.logger.FileLogger

2002-02-19 Thread Kevin Seguin

if a lot of log messages are being written to a file by a lot of threads using 
org.apache.catalina.logger.FileLogger, the output can get messed up so that you get 
things like this:

[timestamp-1] [timestamp-2] [message-1]
[message-2]

instead of this:

[timestamp-1] [message-1]
[timestamp-2] [message-2]

i ran into this while trying to debug bug 5735, which requires a decent load (i.e. 
lots of threads).

attached is a patch with one possible solution  - i could commit this, but i generally 
don't commit on tomcat4, so i'd like some +1's before committing :)

-kevin.


Index: catalina/src/share/org/apache/catalina/logger/FileLogger.java
===
RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/logger/FileLogger.java,v

retrieving revision 1.3.2.1
diff -u -b -r1.3.2.1 FileLogger.java
--- catalina/src/share/org/apache/catalina/logger/FileLogger.java   25 Oct 2001 
20:07:44 -  1.3.2.1
+++ catalina/src/share/org/apache/catalina/logger/FileLogger.java   19 Feb 2002 
+19:44:33 -
@@ -289,13 +289,14 @@
 
 // Log this message, timestamped if necessary
 if (writer != null) {
+synchronized (writer) {
 if (timestamp) {
 writer.print(tsString);
 writer.print(" ");
 }
 writer.println(msg);
 }
-
+}
 }
 
 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: