aspose file tools*
The moose likes Servlets and the fly likes Servlets in multiple JVMs sharing one App log file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets in multiple JVMs sharing one App log file?" Watch "Servlets in multiple JVMs sharing one App log file?" New topic
Author

Servlets in multiple JVMs sharing one App log file?

Gerry Giese
Ranch Hand

Joined: Aug 02, 2001
Posts: 247
Hey folks, got a toughie for ya!
On the app server I'm running there is a log file for each instance of the JVM. We have four CPUs, and four JVMs running. Anything that I log as debug or information using the standard log() or System.out.println() goes to one of the four logs depending on which one is handling the servlet call. This makes debugging and monitoring very messy.
What I would like to do is open a single log file for each web application and let the servlets in that application write to it for debug and info instead of the app server logs. My problem is how to do this when any particular servlet could be running on 4 different JVMs at the same time, and multiple instances of the same servlet could be running on the same JVM, too!
Is there a way to use threading or some built-in J2EE facility to synchronize the log file so it doesn't get trashed, throw exceptions, or generally not work? There's gotta be others who have encountered the same thing.
BTW, I'm not planning on using Log4J or Syslog or any other at this time. We don't have a really high user count nor the time to try and use those. I did create a logging object that I could plug Log4J or other into at a later date, though.
Thanks for your help!


CJP (Certifiable Java Programmer), AMSE (Anti-Microsoft Software Engineer)
Author of Posts in the Saloon
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Why don't you write your log entries to a database, and let it worry about the multi-user thing.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Gerry Giese
Ranch Hand

Joined: Aug 02, 2001
Posts: 247
Yeah, that's always a possibility, but one I was trying to avoid. We poor developers don't have any control over the centralized databases here, and we can't install one on the app server, either. My task is to help application teams convert their apps from NetDynamics (UGH <shudder> ) to J2EE in as little time as possible. Most of the apps are already using the Oracle database, but there's a lot of other groups using the same database already, so there's already a lot of load on the database server and chatter on the network. Plus, making DB calls for logging decreases the response time of the servlets, and DB connection errors and SQLExceptions are some of our major items to log and debug!! The app server is pretty darn quick, having, as I mentioned, 4 CPUS as well as a nice speedy HD array, so I suspect logging to files won't slow things down much. I've already set up a on-the-fly logging configuration for verbosity of the logging so I can turn on/off portions of logging code or all of it without redploying or restarting the server.
Thanks for the suggestion anyway!
Gerry Giese
Ranch Hand

Joined: Aug 02, 2001
Posts: 247
I'm not getting any takers here. Does anyone know if Log4J, Syslog, or any other logging library do automatic synchronization of log files to avoid concurrent write access? If they do I may just be forced to use one of them, which wouldn't be bad, necessarily, just might take a little more effort to integrate with what I've already got.
Thanks for your help!
ray bond
Ranch Hand

Joined: Oct 11, 2000
Posts: 111
hello there Gerry Giese , would you please tell me how to run multiple java virtual machines on a single system , right now my default jvm is programfiles\javasoft\jre.... , how can i make multiple jvm running ??
thanks
Gerry Giese
Ranch Hand

Joined: Aug 02, 2001
Posts: 247
Ray, note on my first message that I'm using an app server. At this time I don't know of any way to run multiple JVMs at the same time besides using an app server. The implementation I'm on is iPlanet, which uses some high-power clustering technology.
Gerry Giese
Ranch Hand

Joined: Aug 02, 2001
Posts: 247
Still looking for answers - anyone? Using the Singleton pattern might be useful, but my concern is it probably only works per JVM, right? I'm assuming that my app server is using 4 JVMs rather than 4 instances of the containers running one JVM. Could I be wrong? Any thoughts?
 
Don't get me started about those stupid light bulbs.
 
subject: Servlets in multiple JVMs sharing one App log file?