Our app servers (weblogic) all use log4j to log to the same file on a network share. On top of this we have all web apps in a managed server logging errors to a common error.log. I can’t imagine this is a good idea but wanted to hear from some pros. I know that each web app has its own classloader, so any thread synchronization only occurs within the app. So what happens when multiple processes start converging on a single log file? Can we expect interspersed log statements? Performance problems? What about multiple web apps logging to a common log file? The environment is Solaris.
Share
This is generaly bad idea to have not synchronized write access to a file and certainly bad programming practice. The only case it might work is an append to a file on local machine – everybody just adds lines at the end of file.
But, since your file is on the network share, it will probably quickly turn into garbage. You didn’t tell which distributed filesystem you are using, but for NFS you can find following explanation on open(2) man page:
Of course this is C, but since Java is implemented in C it cannot do any better than that (at least not with regard to system calls:-)).