views:

42

answers:

1

Hi all,

I'm creating a Java Web Services application. I intend to run multiple instances of WebLogic on each machine in a cluster.

I'd like each application instance to write to its own log file, but I'm not sure how to do so without creating instance specific log4j properties files. Is there some way for me to dynamically determine the WebLogic instance and append it to a log file name? Is there a better way to do this that I haven't seen?

Any insight would be greatly appreciated. Thanks!

Leon

+3  A: 

${weblogic.Name} will give you the name of the Weblogic instance. You can use this as part of the filename within log4j like below.

log4j.appender.file.File=/<path>/myapplog_${weblogic.Name}.log

We also use this attribute within the log file as below

log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss.SSS} ${weblogic.Name} <myapp> [-] %-5p %m \: %c-(%L) %n
JoseK
Sorry for the late response. I did a little research on your suggestion and it worked just as you described. Thanks for this!
Kal