Thursday, April 30, 2015

Adding a Log4j Console to a Web Application

There's a popular open source jsp that allows changing the log4j levels for a web application called log4jAdmin.jsp that I've been wanting to use for troubleshooting, but using it poses a problem. Typically, deployable artifacts are built by an automated process and are not altered as they make their way through the different environments (development/integration/quality assurance/production). I definitely don't want a log4j administration console finding its way into a production environment as this would allow end users to access it.

So the ideal situation would be to add the jsp to the application after it has been deployed. I could have the system administrators add the file to the WebSphere installedApps directory, but this isn't recommended (and they would likely not agree to do this anyways).

A proper alternative is to use WebSphere's deployment process. Instead of updating an application using the default option, look further below on the page:

The contents of the zip should mirror the exploded folder structure in installedApps. In this case the zip contains a single JSP:

Any number of files can be injected into a deployed application using this technique, but in this particular instance I use it to manage Log4j log levels.
Please note that generic comments containing links with the intent of self promotion will be flagged as spam and deleted.


Post a Comment

Are you about to post a generic comment that has nothing to do with this post? Something like "Hey thanks for this very valuable information, BTW here's my website". If so, it will be marked as spam and deleted within 24 hours.

Note: Only a member of this blog may post a comment.