I have 4 java/Java EE applications- Two are server based j2ee applications running in WebSphere. Other two are standalone java applications. My logging framework is log4j using log4j.properties.
Question 1: Can I have a same log file for logging from all the applications. Will it cause any file writing issues even if all the applications are writing at the same time?
Question 2: If all the applications can write without any issues, how can I pre-append the application name to each of the log statement?
Question 1:
I believe by default it will NOT work.
If you are using SLF4J, consider switching to LogBack. In LogBack's File Appender, there is a prudent mode that allow multiple FileAppenders in different JVMs to write to same log file (of course, all of them need to have prudent mode turned on)
http://logback.qos.ch/manual/appenders.html#prudent
Question 2: You should NEVER make the log message different by manually logging your app name.
There are quite some way to do. The easiest way is: As you are having two different applications, you can have different logging config files for them. Just add corresponding app name information in the log pattern used by the appender will serve what you want.