logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Endre StĂžlsvik <En...@Stolsvik.com>
Subject Re: Two JVM's logging to the same file
Date Fri, 05 Nov 2004 08:45:45 GMT
On Thu, 4 Nov 2004, Trond G. Ziarkowski wrote:

| Hi all,
| I have a webapp running under Tomcat, that logs to a file. The db used
| in this webapp needs periodic maintenance, and I have some small apps
| that are run from crontab, that manages this. The information from these
| apps are logged to the same file because of the relevance to webapp
| behavior. It seems that while these apps are running, lines written to
| the log are incomplete and I think that my webapp is acting strange when
| these apps are accessing the log file, when requesting pages the new
| pages are not loaded. No errors are showing up in the tomcat logs, nor
| from any of my apps. I have not tried to log to another file yet in
| production env., I've tried in test env., but my test env. doesn't show
| the same symptoms even when logging to same file. Maybe because of the
| load in production env. is much higher?
| I'm shooting blanks here, so all input on this subject is much appreciated!

You could make a third JVM "server" that accepts incoming socket appenders
from the two (or more) jvms. This server could dump to a file, like
normal. If this really is necessary, that is..!

Two processes, whatever they are (JVM or ordinary stuff), writing to the
same file, will -always- make trouble, on any OS. This is because writes
can really come "on top of each other", and you'll see this as "blocks
written" in your file. So one line would start, being chopped of in the
middle with another line from the other process, and then the rest of the
line of the first - basically, an utter mess - thus you really need some
external synching, either a "OS lock" of some kind (maybe just a
lock-file, but that would be very slow), or as I suggested above, by using
a server that does the internal locking between the two appenders.


To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message