This should do what you want: 1. Switch to XML config. 2. Define your main appender and special appender 3. Use a system property for the name of the file in the special appender. 4. Make sure you have your loggers setup so logs from the special part of your code go to the special appender.
On 2/27/07, DECAFFMEYER MATHIEU <[EMAIL PROTECTED]> wrote:
Thanks for your response, it's not exactly what I want actually : I have a main log where every log is stored, But in a part of my code I want to log in a separate file (and still in the main log file), the location in which I must store the logs of this block of code is told dynamically in my application in a new Log4j file (log4j.appender.file.File=....). So in other words each time I execute this block of code I create a new Log4J file because I must specify a new directory where to store the logs. (e.g. first time I execute the specific block of code store log in directory 21456, second time in 14598, ...) So at the start of this code I do : PropertyConfigurator.configure(...); To load dynamically a new Log4J file (where the new location in which I store the logs is specified) But when I execute this, the logs aren't stored anymore in the main log file. I tried : ApplicationLogManager.info("test1"); PropertyConfigurator.configure(logConfigFileName); ApplicationLogManager.info("test2"); The main log file displays "test1" but nothing anymore below it. That is problem #1. Then when this block of code is exectued, I want to load again the main Log4j file, in the classpath but I don't know how to load this one PropertyConfigurator.configure(??); Maybe I'm doing this all wrong :-) ( :( ) __________________________________ Matt -----Original Message----- From: Jacob Kjome [mailto:[EMAIL PROTECTED] Sent: Monday, February 26, 2007 8:55 PM To: Log4J Users List Subject: Re: Multiple logging files ***** This message comes from the Internet Network ***** Loggers inherit appenders unless they are told not to. If you add an appender to a logger and you want all logging for that logger to go only to the appender you just added to it, you'll have to set additivity="false" to this logger. log4j.additivity.com.mycompany.MyClass=false OR <logger name="com.mycompany.MyClass" additivity="false"> .... </logger> Jake Quoting DECAFFMEYER MATHIEU <[EMAIL PROTECTED]>: > > Hi, > > I have a main log file where all the logs are stored of the application. > But I have a block of instructions in my application and I want the logs > of this code to be stored in another log file. > > So I execute this : > > PropertyConfigurator.configure(...); > > It works ok, but the logs are now stored in both file : > the file I specified in the configure method above > the main log file > > Can anyone help ? > > Thank u. > __________________________________ > > Matt > > > > ============================================ > Internet communications are not secure and therefore Fortis Banque Luxembourg > S.A. does not accept legal responsibility for the contents of this message. > The information contained in this e-mail is confidential and may be legally > privileged. It is intended solely for the addressee. If you are not the > intended recipient, any disclosure, copying, distribution or any action taken > or omitted to be taken in reliance on it, is prohibited and may be unlawful. > Nothing in the message is capable or intended to create any legally binding > obligations on either party and it is not intended to provide legal advice. > ============================================ > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ============================================ Internet communications are not secure and therefore Fortis Banque Luxembourg S.A. does not accept legal responsibility for the contents of this message. The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Nothing in the message is capable or intended to create any legally binding obligations on either party and it is not intended to provide legal advice. ============================================ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- James Stauffer http://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]