tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Creating separate log for each request
Date Wed, 20 Jun 2012 22:22:49 GMT
-----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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message