File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes BEA/Weblogic and the fly likes How to configure Log4j with two managed server? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "How to configure Log4j with two managed server?" Watch "How to configure Log4j with two managed server?" New topic

How to configure Log4j with two managed server?

Cathie Lee

Joined: Nov 20, 2004
Posts: 8
As we are using WebLogic, I post this here for your help.

We have two managed server on one UNIX box and I have the following Log4j Configuration to gather the logs into one log file. But the log got lost during the midnight when it rolled over. So my question is can I configure it to write to the same log file using DailyRollingFileAppender?
If not, what's the best practise for logging applications with two managed servers? Any suggestion will be much appreciated.

Thanks in advance,

<appender name="ABC" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${user.home}/myerror.log"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss:SSS z} %-5p [%t] %C:%M - %m%n"/>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="debug" />
<param name="LevelMax" value="fatal" />
<param name="AcceptOnMatch" value="true" />
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
I don't think that having one log file for two or more processes is a good idea. With the default locking mechanisms on Unix you could easily intermix output from the two and it would be difficult to figure out what information came from what server.

Perhaps a better way would be to have a log file for each server. As the log4j config file can read Java system variables, you could use "weblogic.Name" as one of your parameters. So, for example:

or something like that.

<a href="" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
I agree. Here's the link:
subject: How to configure Log4j with two managed server?
It's not a secret anymore!