Setting Log4j Properties


General J2EE: Setting Log4j Properties

  1. Setting Log4j Properties (5 messages)


    I am revamping a java application. We are planning to user Log4j but I am new to Log4j. My requirement is, I need to use the same log4j property file for 8 different module. I need to know how to configure different file names for different modules in the same log4j file. Thanks for your time

    Threaded Messages (5)

  2. Re: Setting Log4j Properties[ Go to top ]

    You can split your loggers into different files. With the following example, all logging done to loggers in package "com.myco.a" and any subpackage thereof will be logged to module-a.log (likewise for module b). Now, as long as you separate your modules into packages like this, you're ok., A, B

    log4j.appender.A.layout.ConversionPattern=%d{[email protected]:mm:ss} %-5p (%13F:%L) %3x - %m%n

    log4j.appender.B.layout.ConversionPattern=%d{[email protected]:mm:ss} %-5p (%13F:%L) %3x - %m%n
  3. Re: Setting Log4j Properties[ Go to top ]

    I do understand that, but what if I have to use two different loggers in lets say the same class. How do I get the specified logger a, or b?
    Thank you very much for your help!
  4. 2 Logger instances[ Go to top ]

    You just need to create 2 Logger instances using different names.
  5. Re: 2 Logger instances[ Go to top ]

    I have declared fileappender the same way, but some how file is not being generated. what may be the reason?
  6. specify the appender[ Go to top ]

    When declare the "logger" variable, use this to specify de appender: private static Logger logger = Logger.getLogger("com.myco.b");