tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Creating separate log for each request
Date Wed, 20 Jun 2012 22:22:49 GMT
Hash: SHA1


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 {

     = 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
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message