Hello, Here's an idea, thouh I'm not sure it's a clean one... 1. In the contextStarted, get hold of the real path from the servlet context. Let's say you get "/var/tomcat/webapps/myapp/". 2. Set this to a System property e.g. String currentWebAppPath = "/var/tomcat/webapps/myapp/"; System.setProperty("myapp.LogFolder",currentWebAppPath+"logs"; 3. In the log4j.properties file, specify the file path as log4j.appender.A1.File=${myapp.LogFolder}/LogMessages.txt 4. You'll now find all your logs being stored to this folder. You have to have created this folder first ;-) You could always use File.mkdirs() in the contextInitialized...
Now when you change your webapp's foldername, you'll find the logs going to the right location... Note: I don't have access to my comp, so there might be some syntax errors, etc... By the way, have you considered that the servlet container need not expand your app's war ? I run my webapps this way lots of times. If the .war is not going to be expanded, then the logs wont go to the sub folder... And yes, you should post log4J configuration queries to the log4J interest list, after first searching the archives ;-) There's active development going on right now, and you just might get ideas from the developers themselves. Sriram Sriram --- James Adams <[EMAIL PROTECTED]> wrote: > Hello, > > I have tried the ServletContextListener approach suggested below by > Sriram (thanks !) and I am still having the same problem, i.e. I get the > log file (specified in my log4j.properties file) created under whatever > directory I am at when I issue the tomcat start command. It appears > that the log file is being created and placed in the current working > directory if I specify only the file name in the log4j.properties > "File" entry. If I specify the full path, such as > > log4j.appender.A1.File=/var/tomcat/webapps/myapp/LogMessages.txt > > then it creates and places the file exactly where it the entry > specifies. But I want to just specify the filename and have it created > under the webapp's context directory, that way I won't have to remember > to change the log4j.properties entry whenever the webapp is moved to > another context directory or installed on another machine which might > have a different webapps directory path. > > So is there a way to get the log file to be created and placed under its > webapp's context directory ? > > Also would it be more appropriate to post this topic/thread to the log4j > user group ([EMAIL PROTECTED]) ? > > Thanks in advance for any suggestions or clues. > > > -James __________________________________________________ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards® http://movies.yahoo.com/ -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>