Discussions

General J2EE: How to use and configure log4j in cluster environment ?

  1. I want to use log4j in weblogic cluster enviornment. Please share your thoughts and experiences on this.

    Asha
  2. If I understand your request, you want to centralize logging in a multi-server, clustered environment.

    I guess there could be a couple of options

    1. Log to a database.

    2. Use JMS to log to a queue. If I remember correctly, WL, since 4.51, comes with a message queue server.
  3. Without creating a 3rd server, how would you use WL's JMS server to centralize the logging? Wouldn't it be like using JMS on each machine as a Log4J appender to mearly log to a central data store?
  4. I know it is an old thread, but maybe someone will need the solution I'm using. I configure file appender so that it uses weblogic.Name system property that is set by default inside weblogic server. In that case I have separate log4j files for different servers. The configuration looks like this:
  5. I know it is an old thread, but maybe someone will need the solution I'm using. I configure file appender so that it uses weblogic.Name system property that is set by default inside weblogic server. In that case I have separate log4j files for different servers. The configuration looks like this:

    Hi Srecko, Would this substitution ${weblogic.Name} work for log4l.properties? Or it works only in xml config files? BTW, do you have any suggestion if one wanted to use one common file (DailyRollingFileAppender) placed in shared folder (mount point)? What we observe is that one instance rolls on file to a new day, but other instance still writing to the previous day logs...any solution for this? Log4j socket server can't be used since it is not fault tolerant (e.g. if socket server down or box it is running on down - we have no logs)
  6. Old post, but just to let you know, ${weblogic.Name} works fine in log4j.properties. Best to keep log files separate in a cluster so it's easier to trace what each server is doing, concurrency issues, etc.

    Example line:

    log4j.appender.MyLog.File=/path/to/logfile/log-${weblogic.Name}.log

     

  7. Performance will surfer if log directly into a DB. Syslog is a common tool used by many companys. Scribe is another one develop and used by facebook.

  8. log4j in clustered env[ Go to top ]

    0 down vote

    check this link http://stuffjava.blogspot.in/2012/06/set-log4j-file-name-at-runtime-in.html

  9. reply[ Go to top ]

    This  might help you

    The steps involved in using log4j are:

    1. Write a configuration file. In this file:

    • Specify the level of the root logger and attach an appender to it.
    • Specify the properties of the appender.
    • Specify a layout for the appender.

    2. In your code, acquire a logger by class or name. Typically, this should be the logger associated with the current class.

    3. Start logging using any of the methods of the logger you acquired in step 2 (log.debug(), log.info(), log.warn(),log.error(), log.fatal()).

     

    how stop smoking