Ok,

I have set the system property before to initializing log4j

(just as test :
                System.setProperty("log.name","temp.log");
                DOMConfigurator.configure(PATH_TO_LOGS+"log4j.xml");
)

Then I change dynamically the system property to change the directory in
which the logs need to be stored :
System.setProperty("log.name",idRequest+".log");

But the logs keeps getting stored in temp.log 

__________________________________
   Matt

    

-----Original Message-----
From: James Stauffer [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 28, 2007 2:14 PM
To: Log4J Users List
Subject: Re: Multiple logging files

*****  This message comes from the Internet Network *****

3. Both the system property and any needed directories need to be set
before log4j is configured.  I created an appender that can create
directories as needed and it is at
http://stauffer.james.googlepages.com/DateFormatFileAppender.java

4. In your code you don't refer to a special appender, you refer to
special loggers.
i.e
Logger logger = Logger.getLogger(getClass().getName());
Logger specialLogger = Logger.getLogger("special." +
getClass().getName());

  <logger name="special">
    <level value="info"/>
    <appender-ref ref="specialAppender" />
  </logger>

  <root>
    <priority value ="info" />
    <appender-ref ref="mainAppender" />
    <appender-ref ref="consoleAppender" />
  </root>

On 2/28/07, DECAFFMEYER MATHIEU <[EMAIL PROTECTED]> wrote:
> For the System property issue I tried this :
>
>       <appender name="specialAppender"
> class="org.apache.log4j.DailyRollingFileAppender">
>           <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
>           <param name="File"
> value="C:/UserTemp/matthew016/${log.name}"/>
>           <layout class="org.apache.log4j.PatternLayout">
>                <param name="ConversionPattern" value="%d{ISO8601} %-5p
> [%-30.30c{2}] %m%n"/>
>           </layout>
>       </appender>
>
> And in my Java applciation I execute this line before I need to log in
> the special appender :
>
> System.setProperty("log.name",idRequest+".log");
>
> [2/28/07 12:16:32:297 CET] 3e89f5a2 SystemErr     R log4j:ERROR
> setFile(null,true) call failed.
> [2/28/07 12:16:32:297 CET] 3e89f5a2 SystemErr     R
> java.io.FileNotFoundException: C:\UserTemp\matthew016 (Access is
denied)
>
> Though something like this <param name="File"
> value="C:/UserTemp/matthew016/myLog.log"/> works.
>
> I tried also a simple thing :
> If I do this :
> <param name="File" value="C:/UserTemp/matthew016/updates/myLog.log"/>
>
> [2/28/07 12:15:17:669 CET] 3e8d3584 SystemErr     R log4j:ERROR
> setFile(null,true) call failed.
> [2/28/07 12:15:17:669 CET] 3e8d3584 SystemErr     R
> java.io.FileNotFoundException: C:\UserTemp\matthew016\updates\test.log
> (The system cannot find the path specified)
>
> It gives me the same error, because it cannot find the directory
> "updates" under dir "matthew016".
> Though I create this dir dynamically in my application *before* any
logs
> need to be stored trhough the appender specified output.
>
> __________________________________
>    Matt
>
>
>
> -----Original Message-----
> From: DECAFFMEYER MATHIEU [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 28, 2007 9:58 AM
> To: Log4J Users List
> Subject: RE: Multiple logging files
>
> *****  This message comes from the Internet Network *****
>
> Yes exactly  :-) Thank u very much,
> I realized I did this all wrong.
>
> I have read the Log4J tutorial,
>
> I did the points 1 & 2, but for I have some difficulties on how to
> implement point 3 & 4
>
> I switched this to XML :
>
>           <appender name="mainAppender"
> class="org.apache.log4j.FileAppender">
>                    <param name="DatePattern"
value="'.'yyyy-MM-dd-HH"/>
>            <param name="File" value="C:/UserTemp/matthew016/app.log"/>
>            <layout class="org.apache.log4j.PatternLayout">
>                <param name="ConversionPattern" value="%d{ISO8601} %-5p
> [%-30.30c{2}] %m%n"/>
>            </layout>
>           </appender>
>       <appender name="specialAppender"
> class="org.apache.log4j.FileAppender">
>           <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
>           <param name="File" value="C:/UserTemp/matthew016/
>>>>SYSTEM
> PROPERTY<<<< "/>
>           <param name="File" value="C:/UserTemp/matthew016/app.log"/>
>           <layout class="org.apache.log4j.PatternLayout">
>                <param name="ConversionPattern" value="%d{ISO8601} %-5p
> [%-30.30c{2}] %m%n"/>
>           </layout>
>       </appender>
>       <appender name="consoleAppender"
> class="org.apache.log4j.ConsoleAppender">
>           <layout class="org.apache.log4j.PatternLayout">
>                <param name="ConversionPattern" value="%-5p %c{1} -
%m%n"
> />
>           </layout>
>       </appender>
>           <root>
>             <priority value ="info" />
>             <appender-ref ref="mainAppender" />
>             <appender-ref ref="specialAppender" />
>             <appender-ref ref="consoleAppender" />
>           </root>
>
>
> *  In my Java class I don't know how I can specify which appender I
> should use,
>    Or maybe I can specify the logger in the log4j.xml file ?
>
> *  I don't knwo how to use the system property,
>    In the program I suppose I just need to do something like this :
> System.setProperty("myProp","updates/"+dirNumber);
>    But what do I need to specify in the XML file ?
>
> *  Is it correct what I did in the special appender ? I specified the
> file which must include the system property and the same file as the
> main appender,
>    is this the good way.
>
>
> Thank u for any hints!
>
> __________________________________
>    Matt
>
>
>
> -----Original Message-----
> From: James Stauffer [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 27, 2007 5:47 PM
> To: Log4J Users List
> Subject: Re: Multiple logging files
>
> *****  This message comes from the Internet Network *****
>
> 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]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> 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]



============================================
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]

Reply via email to