Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets in multiple JVMs sharing one App log file?

 
Gerry Giese
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you write your log entries to a database, and let it worry about the multi-user thing.
 
Gerry Giese
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic