Re: Creating separate log for each request
On 20.06.2012 23:35, Lahiru Gunathilake wrote: Hi Jeff, Thanks for the response, actually my requirement is to make the life easier for the admin, and if something goes wrong he has an ID of the request which failed (This is not a system which is getting millions of http requests) and then he should be able to figure out the logs for that request based on the ID he has. If you have a solution for that, kindly let me know, I am happy to use it.. Many log frameworks support setting a thread local and adding it to every log message as part of the log format configuration. For SLF4J look for Mapped Diagnostic Context in http://www.slf4j.org/manual.html Assuming your batch type request handling is using only a single thread for each request, you can put the request ID into the MDC and add the MDC automatically to every log message you produce during the run of this request (by simply adding it to the log format configuration instead of adding it to each log statement). Then your admins can simply grep/search for the request ID in the log file. Regards, Rainer - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Creating separate log for each request
On 20/06/2012 22:39, Lahiru Gunathilake wrote: Hi Caldarale, Its not a website.. I am hosting a middleware which will be used by scientist to run their application in the Grid. So Ideal scenario is like 2--30 requests per day but they are long running and very time consuming (Some jobs would take 2,3 days or one week to finish), so the logs are very important. If there are only a few requests per day how can it be that hard to search the log file? p Lahiru On Wed, Jun 20, 2012 at 5:35 PM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Lahiru Gunathilake [mailto:glah...@gmail.com] Subject: Creating separate log for each request I am using slf4j for my logging and everything works fine and all the logs comes to catalina.out. Which means that things are seriously broken or incredibly badly configured. Logging should *never* go to catalina.out in a properly configured system. I simply want to create a separate log for each http request come to my tomcat instance. You can't be serious. How much traffic does your website get? - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org -- [key:62590808] signature.asc Description: OpenPGP digital signature
Re: Creating separate log for each request
Are you sure of that, a single file for a single HTTP request. I don't know a file system capable to handle that ? Jeff On Wed, Jun 20, 2012 at 10:38 PM, Lahiru Gunathilake glah...@gmail.comwrote: Hi All, I have my webapp deployed on tomcat. I am using slf4j for my logging and everything works fine and all the logs comes to catalina.out. But I have a requirement of creating a separate log for each request comes to my webapp... I only have single webapp, so I simply want to create a separate log for each http request come to my tomcat instance. Anybody knows how to do this in tomcat configuration ? Regards Lahiru -- System Analyst Programmer PTI Lab Indiana University -- Jeff MAURY Legacy code often differs from its suggested alternative by actually working and scaling. - Bjarne Stroustrup http://www.jeffmaury.com http://riadiscuss.jeffmaury.com http://www.twitter.com/jeffmaury
Re: Creating separate log for each request
Hi Jeff, Thanks for the response, actually my requirement is to make the life easier for the admin, and if something goes wrong he has an ID of the request which failed (This is not a system which is getting millions of http requests) and then he should be able to figure out the logs for that request based on the ID he has. If you have a solution for that, kindly let me know, I am happy to use it.. Regards Lahiru On Wed, Jun 20, 2012 at 5:12 PM, Jeff MAURY jeffma...@jeffmaury.com wrote: Are you sure of that, a single file for a single HTTP request. I don't know a file system capable to handle that ? Jeff On Wed, Jun 20, 2012 at 10:38 PM, Lahiru Gunathilake glah...@gmail.com wrote: Hi All, I have my webapp deployed on tomcat. I am using slf4j for my logging and everything works fine and all the logs comes to catalina.out. But I have a requirement of creating a separate log for each request comes to my webapp... I only have single webapp, so I simply want to create a separate log for each http request come to my tomcat instance. Anybody knows how to do this in tomcat configuration ? Regards Lahiru -- System Analyst Programmer PTI Lab Indiana University -- Jeff MAURY Legacy code often differs from its suggested alternative by actually working and scaling. - Bjarne Stroustrup http://www.jeffmaury.com http://riadiscuss.jeffmaury.com http://www.twitter.com/jeffmaury -- System Analyst Programmer PTI Lab Indiana University
RE: Creating separate log for each request
From: Lahiru Gunathilake [mailto:glah...@gmail.com] Subject: Creating separate log for each request I am using slf4j for my logging and everything works fine and all the logs comes to catalina.out. Which means that things are seriously broken or incredibly badly configured. Logging should *never* go to catalina.out in a properly configured system. I simply want to create a separate log for each http request come to my tomcat instance. You can't be serious. How much traffic does your website get? - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Creating separate log for each request
Hi Caldarale, Its not a website.. I am hosting a middleware which will be used by scientist to run their application in the Grid. So Ideal scenario is like 2--30 requests per day but they are long running and very time consuming (Some jobs would take 2,3 days or one week to finish), so the logs are very important. Lahiru On Wed, Jun 20, 2012 at 5:35 PM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Lahiru Gunathilake [mailto:glah...@gmail.com] Subject: Creating separate log for each request I am using slf4j for my logging and everything works fine and all the logs comes to catalina.out. Which means that things are seriously broken or incredibly badly configured. Logging should *never* go to catalina.out in a properly configured system. I simply want to create a separate log for each http request come to my tomcat instance. You can't be serious. How much traffic does your website get? - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org -- System Analyst Programmer PTI Lab Indiana University
Re: Creating separate log for each request
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Lahiru, On 6/20/12 5:39 PM, Lahiru Gunathilake wrote: Hi Caldarale, Its not a website.. I am hosting a middleware which will be used by scientist to run their application in the Grid. So Ideal scenario is like 2--30 requests per day but they are long running and very time consuming (Some jobs would take 2,3 days or one week to finish), so the logs are very important. If you need requests to take 2-3 days, then HTTP is not the protocol for you. Are you accepting batch requests via HTTP and then working on them after the request/response has completed? That would make more sense. In any case, most logging frameworks create Log (or Logger) objects that live for a long time: they aren't set up to create a Log/Logger, use it for a bit and then discard it, since loggers tend to get used for the life of the JVM. I think what you want is a simple FileWriter. You can even use the existing logging framework's log-level-checks if you want, like this: PrintWriter out = null; try { if(logger.isDebugEnabled()) = new PrintWriter(FileWriter(/logs/job- + jobId)); ... if(null != out) out.println(Got an interesting value: + interestingValue); ... } finally { if(null != out) try { out.close(); } catch (IOException ioe) { logger.error(Couldn't close job log, ioe); } } - -chris -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/iTTkACgkQ9CaO5/Lv0PDW2gCfRuyYHaUZ8hNbmeKSw/wBmdsD XuIAnRG0NjBmPrsNT8RCDFuvZIbzYIGH =k33J -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org