On Fri, Jun 6, 2008 at 9:43 AM, Ning Zhao <[EMAIL PROTECTED]> wrote: > Hi all! > > in my log4cxx.properties file, I'd like to write the output log file name in > this way: > > log4j.appender.R.File=%h/myApp%g.log > > where %h means my home directory and %g means the generated file name > suffix. For example, myApp0.log, myApp1.log, myApp2.log, .... > > ( Please see > http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/FileHandler.html ) > > I tried but it did not work. Is the feature I wanted available at all in > log4cxx? If not, any solution/work around? Many thanks in advance! > > > Best Regards, > Ellen N. Zhao > > -- > HaCon Ingenieurgesellschaft mbH > Lister Str. 15 > 30163 Hannover > Germany/Deutschland > Tel. +49 511 33699-363 > Fax. +49 511 33699-99 > Email: [EMAIL PROTECTED] > http://www.hacon.de > > Registry Court/Amtsgericht Hannover HRB 1712 > Managing Directors/Geschäftsführer: Michael Frankenberg, > Dr.-Ing. Marian Gaidzik, Dr.-Ing. Werner Kretschmer, > Werner Sommerfeld, Dr.-Ing. Volker Sustrate, Peter Talke >
As far as the home directory part log4cxx does support expanding environment variables in the form of ${VARIABLE}. For the other part I think you want a RollingFileAppender. Note there are two different RollingFileAppenders: org.apache.log4j.rolling.RollingFileAppender org.apache.log4j.RollingFileAppender The first one cannot be configured from a properties file (requires XML configuration). It is more general purpose but is more complex to configure. The second one is more equivalent to the class you linked to. The equivalent file pattern on windows would be: ${USERPROFILE}/myApp%i.log -- Dale King