Howdy,
A couple of ideas come to mind:
- Start with a default logging directory, e.g. java.io.tmpdir. Configure log4j
using the property configurator's configureAndWatch method. Then when the user
changes logdir, programatically edit the file to reflect the changes. Log4j
will pick the changes up automatically.
- Or you could reconfigure log4j yourself when the user changes the log
directory. As long as you know the appender's name (A1 in your example below),
you can get at it programmatically to retrieve its layout and file name. You
can then create a new appender programatically, remove the old one, and add the
new one.
- You could use a system property, e.g. -DmyLogDir=blah. Keep ${myLogDir} in
your properties file. When the user changes the log dir, change the system
property value and reconfigure log4j.
I don't think the requirement is particularly clean, so none of the solutions
are squeaky clean...
Yoav Shapira
--- r abiram <[EMAIL PROTECTED]> wrote:
> Hi ,
> I have one Query hope you wont mind giving me the
> better solution I want to know one information for
> logging using the properties file
> Now our requirement of logging is to change the "log
> directory" dynamically as selected by user once he
> enters the values in log file
> Is there any way to achieve this using Properties file
>
> To be more brief We take the some of the parameter
> Filename,Host &port from the properties file where I
> have done the logging
> & get this values & use in the programm
> but in case of the Log directory I am not specifying
> the log directory in programme
> but I have to use this same variable in the
> properties file itself
> example
> *******************
> Filename=TEST.txt
> host=QM_TEST
> logDir= c:\infi\log
> ------------------log4j. Etc ------
> ----------------log4j.etc ------------
> log4j.appender.A1.File=${logDir}/DpbatDev.log (note
> above
> logDir=c:\infi\log)
> *******************
> now I get the value of Filename & host in the prog
> but how to substitute the value of logDir to the same
> property file some where in bottom.
> log4j.appender.A1.File=${logDir}/DpbatDev.log (note
> above
> logDir=c:\infi\log)
> as seen above I have to replace the logDir with the
> value of the directory specified in the same file but
> it does not work
> Is there any syntax in properties file which I can
> call to know the value of logDir in the bottom as
> entered in the top by user. If you have any idea
> please let me know Regards, Abiram
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
=====
Yoav Shapira
[EMAIL PROTECTED]
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]