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 t开发者_如何转开发o 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
${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
Just found out that you have to use ${sys:weblogic.Name}
if you are using log4j2.
精彩评论