Where to store log files from packed WAR file apps
Hello Now that I've got my Ant build/deploy scripts working nicely, I'm tempted to start running my applications out of packed WAR files. I cannot figure out if there is a *portable* way to specify paths for where my Log4J log files should be saved. I assume I could use the 'catalina.home' property to save the logs under the Tomcat installation directory - but that's Tomcat specific. Has anyone got around this, somehow, or is it a case of getting Ant to glue things with some hard-coded values at build time? Many thanks for any contributions. Harry Mantheakis London, UK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Where to store log files from packed WAR file apps
Might be wrong on this but why not setup environment variables and reflect those in ant? That way you should be portable, providing those env vars exist. BTW, take off the tomcat greeting page from your machine ;) -Original Message- From: Harry Mantheakis [mailto:[EMAIL PROTECTED] Sent: 03 March 2004 09:34 To: Tomcat Users List Subject: Where to store log files from packed WAR file apps Hello Now that I've got my Ant build/deploy scripts working nicely, I'm tempted to start running my applications out of packed WAR files. I cannot figure out if there is a *portable* way to specify paths for where my Log4J log files should be saved. I assume I could use the 'catalina.home' property to save the logs under the Tomcat installation directory - but that's Tomcat specific. Has anyone got around this, somehow, or is it a case of getting Ant to glue things with some hard-coded values at build time? Many thanks for any contributions. Harry Mantheakis London, UK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. Note:__ This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Jaguar Freight Services and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs.
RE: Where to store log files from packed WAR file apps
Hi, Might be wrong on this but why not setup environment variables and reflect those in ant? That way you should be portable, providing those env vars exist. BTW, take off the tomcat greeting page from your machine ;) That's one possible solution. Another is to setup a build.properties file with tokens, e.g. @logfile@ and have the ant deploy script populate your web.xml (or whatever configuration file you want) with the appropriate value of this token. (See Ant's copy filter token mechanisms). Yet another approach, and probably the most enterprise like, is to specify the log file location via JNDI. Have an env-entry-ref in your web.xml (this is constant, will not changed, so you don't need to change your WAR), and have the server administrator fill in the appropriate value for their server (e.g. in server.xml for tomcat). Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where to store log files from packed WAR file apps
You should never log to within the directory structure of your webapp if you want your app to be portable. Provide configuration in web.xml as to where you want the log file to go which an admin can override via proprietary configuration. For instance, in Tomcat... Context ... Parameter name=log4j-log-location value=C:\logs override=false description=Location for logs to be written/ /Context Then in your Log4j initialization, use value of the log4j-log-location context-param and set a system property with that value to a name that you reference in your log4j.xml file such as appender name=File class=org.apache.log4j.RollingFileAppender param name=File value=${log.location} / .. .. .. /appender Or, check out the logging-log4j-sandbox project and grab the alpha_2 (I think that's the tag name) tag. Then look into ServletContextLogAppender which will allow you to specify this in log4j.xml appender name=ServletContext class=org.apache.log4j.servlet.ServletContextLogAppender param name=servletContextPath value=/mycontext / layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=[%-5p][%-8.8t]: %39.39c{3} - %m/ /layout /appender The output will be routed through your server's context.log() mechanism. In Tomcat, just set up Context path=/mycontext docBase=mycontext.war debug=5 reloadable=true Logger className=org.apache.catalina.logger.FileLogger prefix=localhost_mycontext_servlet_log. suffix=.txt timestamp=true / /Context Now you don't need to configure any file to do the logging. It will just show up in your container's log directly which you know for a fact will exist and the container will create it for you. Or, use Chainsaw2... http://logging.apache.org/log4j/docs/chainsaw.html Jake Quoting Harry Mantheakis [EMAIL PROTECTED]: Hello Now that I've got my Ant build/deploy scripts working nicely, I'm tempted to start running my applications out of packed WAR files. I cannot figure out if there is a *portable* way to specify paths for where my Log4J log files should be saved. I assume I could use the 'catalina.home' property to save the logs under the Tomcat installation directory - but that's Tomcat specific. Has anyone got around this, somehow, or is it a case of getting Ant to glue things with some hard-coded values at build time? Many thanks for any contributions. Harry Mantheakis London, UK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where to store log files from packed WAR file apps
Thanks to everyone for the replies to my question! Lots there for me to look into - JNDI, Alpha_2, and Chainsaw. Phew! Sorry, for *my* slow response: my ISP has dropped all my mail today, of all days - so I went online to get your answers. Regards Harry Mantheakis London, UK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where to store log files from packed WAR file apps
Thanks to everyone for the replies to my question! Lots there for me to look into - JNDI, Alpha_2, and Chainsaw. Phew! Sorry, for *my* slow response: my ISP has dropped all my mail today, of all days - so I went online to get your answers. Regards Harry Mantheakis London, UK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]