One thing you can do today is to merge a properties file into System.properties. A nicer solution is for the DOMConfigurator do read a properties file passed as argument to log4j:configuration. I'll add it to the todo list. Ceki At 14:08 16.03.2001 -0500, you wrote: >This looks great, but ... :-) can I do something similar with a DOMConfigurator? >I looked, but I did not see a way to define a custom property with a log4j.dtd >XML file and the DOMConfigurator. I would really like to be able to do the exact >same thing within a log4j xml file. The DOMConfigurator calls an internal a >subst function that uses OptionConverter.substVars with a data member props. But >props looks like it will always be null (it is never set at least that I could >see) so only the System properties are used. This means, I can still use a >custom property, message.ConversionPattern, when defining a layout's conversion >pattern as in > ><layout class="org.apache.log4j.PatternLayout"> > <param name="ConversionPattern" > value="${message.ConversionPattern}" /> ></layout> > >but I have to externally add the property "message.ConversionPattern" to the >System properties. Is there a better way to do this? (I am using 1.1b1 and am a >log4j newbie, so my apologies if this is a dumb question.) > >Ideally, I think it would be nice to extend the dtd so that the >log4j:configuration element takes zero or more param elements. The >DOMConfigurator can add all the params to its internal props Properties data >member and then one could define any custom properties with > ><log4j:configuration> > <param name="message.ConversionPattern" > value= "%t %-5p %c{2} - %m%n" /> > >... rest of config.xml can now use ${message.ConversionPattern} > >without needing a second properties file. Does this make sense to fold into >DOMConfigurator? > >Thanks for your help and for making log4j available. > >Phil > >Ceki Gülcü wrote: > >> How about: >> >> configDir = /usr/local/my_project/prod/logs >> >> log4j.category.my_category=INFO, MY_Appender1, MY_Appender2, MY_Appender3, >> MY_Appender4, MY_Appender5, MY_Appender6, MY_Appender7 >> ... >> log4j.appender.MY_Appender1.File=${configDir}/trace1.log >> ... >> log4j.appender.MY_Appender2.File=${configDir}/trace2.log >> ... >> log4j.appender.MY_Appender3.File=${configDir}/trace3.log >> ... >> log4j.appender.MY_Appender4.File=${configDir}/trace4.log >> ... >> log4j.appender.MY_Appender5.File=${configDir}/trace5.log >> ... >> log4j.appender.MY_Appender6.File=${configDir}/trace6.log >> ... >> log4j.appender.MY_Appender7.File=${configDir}/trace7.log >> >> Log4j supports variable substitution in config files. Hope this helps. Ceki >> >> At 15:34 14.03.2001 -0800, Greg Knight wrote: >> >Hello, >> > >> >I am playing with Log4J using both FileAppender and RollingFileAppender. In >> >defining the appenders (via a config file), I have a line similiar to: >> > >> >log4j.appender.MY_Appender1.File=trace.log >> > >> >My question is how do I make path to trace.log relative? The path will >> >change based on the environment in which the code executes. For example, the >> >fulll path in development might be c:\my_project\dev\logs\trace.log. In QA >> >the path might be /usr/local/my_project/qa/logs/trace.log. In production it >> >might be /usr/local/my_project/prod/logs/trace.log. >> > >> >While it is not that difficult to just change the config file, I would >> >rather not have to put the full path in the config file for each file >> >appender. The problem exacerbates when I have numerous file appenders >> >declared in the config file. Each one would need to be different depending >> >on which environment the code is hosted. Additionally, if I share the config >> >file with other developers on the project, they will have to modify each >> >file appender in the config file if their directory structure is different. >> > >> >What I would really like to do is following: >> > >> >/********************** config file ********************************/ >> >configDir = /usr/local/my_project/prod/logs/ >> > >> >log4j.category.my_category=INFO, MY_Appender1, MY_Appender2, MY_Appender3, >> >MY_Appender4, MY_Appender5, MY_Appender6, MY_Appender7 >> >... >> >log4j.appender.MY_Appender1.File=trace1.log >> >... >> >log4j.appender.MY_Appender2.File=trace2.log >> >... >> >log4j.appender.MY_Appender3.File=trace3.log >> >... >> >log4j.appender.MY_Appender4.File=trace4.log >> >... >> >log4j.appender.MY_Appender5.File=trace5.log >> >... >> >log4j.appender.MY_Appender6.File=trace6.log >> >... >> >log4j.appender.MY_Appender7.File=trace7.log >> > >> >// other stuff >> > >> >/************** end of config file *****************************/ >> > >> >/************ Java code *************************************/ >> > >> >PropertyConfigurator.configure("config"); >> >Enumeration appenders = cat.getAllAppenders(); >> >while (appenders.hasMoreElements()) >> >{ >> > Appender = (Appender) appenders.nextElement(); >> > if (Appender instanceOf FileAppender) >> > { >> > FileAppender fa = (FileAppender) Appender; >> > fa.setPath(props.getProperty("configDir"); // >> >how do I do this >> > } >> >} >> > >> >Thanx, >> >GK >> > >> >--------------------------------------------------------------------- >> >To unsubscribe, e-mail: [EMAIL PROTECTED] >> >For additional commands, e-mail: [EMAIL PROTECTED] >> >> I hope to see you at my ApacheCon 2001 presentation >> entitled "Log4j, A Logging Package for Java". >> >> See http://ApacheCon.Com/2001/US/ for more details. >> >> ---- >> Ceki Gülcü Web: http://qos.ch >> av. de Rumine 5 email: [EMAIL PROTECTED] (preferred) >> CH-1005 Lausanne [EMAIL PROTECTED] >> Switzerland Tel: ++41 21 351 23 15 >> >> --------------------------------------------------------------------- >> 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] I hope to see you at my ApacheCon 2001 presentation entitled "Log4j, A Logging Package for Java". See http://ApacheCon.Com/2001/US/ for more details. ---- Ceki Gülcü Web: http://qos.ch av. de Rumine 5 email: [EMAIL PROTECTED] (preferred) CH-1005 Lausanne [EMAIL PROTECTED] Switzerland Tel: ++41 21 351 23 15 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]