0

I have a war file that I deploy using the websphere console. Everytime a new version of the application is deployed or the application is started I would like to delete some files in a websphere log directory on my linux filesystem.

i.e. 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/mySubFolder

I would like peoples thoughts on what the right way to do this is.

I have heard of jacl scripts before but don't know if I should be heading in that direction. Also if I do go down the jacl script path can I write a jacl script for a war or does it have to be an ear?

thanks

Richie
  • 4,989
  • 24
  • 90
  • 177

1 Answers1

1

You could probably configure ServletContextListener in your web.xml.

<web-app ...>
   <listener>
    <listener-class>
             com.example.MyServletContextListener 
        </listener-class>
   </listener>
</web-app>

MyServletContextListener.contextInitialized(...) will be called every time application is started. Of course websphere process will need permissions to delete those files.

skegg99
  • 415
  • 2
  • 8
  • Thanks. I'll try this and let you know how I go. Is removing logs files on your file system something you might typically do using the servlet context filter? – Richie Apr 13 '15 at 04:44
  • I can't really think of a reason to delete log files on app deploy or start. Log files are supposed to be rotated. Configuration options for log rotation fulfill all my needs. – skegg99 Apr 14 '15 at 08:53
  • Yes I agree. But there is a module in my webapp which has it's own logging mechansim and it is too compicated to redirect the logs to a log4j rollingAppender. So I've just put them in a directory on the side and want them deleted everytime the application is restarted. – Richie Apr 14 '15 at 09:23