So, if you use the standard log4j servlet approach to start your logging, you can weave in the following to set your path relative to your app:
org.w3c.dom.NodeList nodes = doc.getElementsByTagName("param");;
org.w3c.dom.Node node = null;//nodes.item(0);
org.w3c.dom.NamedNodeMap nodeMap = null;
for(int i=0; i < nodes.getLength(); i++)
{
node = nodes.item(i);
nodeMap = node.getAttributes();
if(nodeMap.getNamedItem("name")
.getNodeValue().equals("File"))
{
node = nodeMap.getNamedItem("value");
outputFile = new File(getServletContext().getRealPath(node.getNodeValue()));
outPutPath = outputFile.getAbsolutePath();
outPutPath = outPutPath.replace('', '/');
node.setNodeValue(outPutPath);
}
}
Then you can set the log location to outPutPath.
Enjoy :)
No comments:
Post a Comment