Your specific problem is that you need to mutex around access to your file. You have not factored in the multi-threaded environment in which you are operating. Anyway, there are better solutions than having a class that writes to a log file, which is invoked by many client threads. What if your components are spread over many JVMs and servers? How will you scale your current approach? A better approach is to have a system singleton that acts as a logging service. Depending on the EJB environment you are using, you can use RMI or CORBA for this purpose. One approach I like is the use an EventLogger based on a CORBA Event channel. The nice thing about this approach is that Event suppliers and consumers are de-coupled. This way you can attach and detach various Event consumers that write to log files, JDBC based storage or a Console. So for example your main logger could be writing to a JDBC based log, but if you wanted to sniff current events which are being logged, you could attach and event consumer which simple dumps to your Console. <vendor> In GemStone/J we provide the above as a goodie to our customers. The Event log writes are buffered and dispatched asynchronously so that client threads do not block after submitting an event to log... </vendor> -Chris. > -----Original Message----- > From: Sanjay Nambiar [SMTP:[EMAIL PROTECTED]] > Sent: Saturday, November 20, 1999 7:53 AM > To: [EMAIL PROTECTED] > Subject: Java implementation Query:Urgent > Importance: High > > Hi All, > Sorry to post this mail on this mailing list.But if some one could provide > a > solution..... > We have "probably" a preliminary query. > In our application we would like to write to one log file by multiple > processes.The problem we are facing is as follows: > We have to implement one log class which would be static and a method of > that class would be called by the respective > applications. > > During writing to the file, the messages are being Garbled as shown below. > Error Num Insert query is as follows:"....." > Where the string "Error Num" actually is a complete string "Error Number > is > :100 ISAM Query" . > > This is because multiple applications are trying to write to the file at > the > same time. > We have implemented RandomAccessFile.Method is > RandomAccessFile.WriteBytes() > We request for a solution in terms of brief pointers or a detailed > solution. > > Regards, > SANJAY Nambiar > > ========================================================================== > = > To unsubscribe, send email to [EMAIL PROTECTED] and include in the > body > of the message "signoff EJB-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
