Hi Shankar:

Two other people asked this same question so if you don't mind, I'll
post my (simple) solution to the list.  Btw, for those who don't
remember, this is a way to enable changes in log4j.properties to be seen
by the application without a server reboot.  Here goes:

1. Create a simple action class say ReloadLog4jAction with just a couple
of statements in the perform/execute method: Create a new LogManager,
then call its resetConfiguration() method. (Write the class within the
application context where you want your log4j.properties file
reconfigured)
2. Create the appropriate action mapping in your struts-config.xml, so
that (say) /admin/reloadLog4j.do would map to this class and maybe
redirect to an "OK" page. (am following the way /admin/reload.do works).

3. Reload struts-config either by server restart (or simply by calling
/admin/reload.do if you have that mapping in your struts-config.xml.) Of
course you will need to do this just once..
4. Make any changes to your log4j.properties file and then point your
browser now to the url /admin/reloadLog4j.do. The log4j.properties file
will then be reloaded and after your OK page displays, the new
log4j.properties file will then be read in.

Really simple and works so nicely..:)
Regards,
Geeta

shankarr wrote:

> Hi Geeta,
>
> If you could let me know how to achieve the integration will be great.
>
> Where have you written the class which observes the file?
> What I mean is, where in the struts framework are u using it at the
> RequestProcessor level or what.
> As I understand, in order for making the struts application in itself
> monitor the file, I need to write some init file only .
> Which class to extend and where do I put the entries.
> Sample code for the class file and the web.xml entries will be greatly
> appreciated.
>
> Shankar
>
> "To achieve all that is possible, one must attempt the impossible"
>

Reply via email to