0

We are developing a Java Platform as a Service (yes, another one!) for the java developers in our organization. Now we are in the point of asking ourselves, hey, what are we going to do with the logs?

As container we are using tomcat 7, so for the catalina logs it is clear: http://tomcat.apache.org/tomcat-7.0-doc/logging.html and follow the wise guidelines that Mark Thomas point out in this presentation (around minute 10...)

But how can I limit the size of the web applications logs? Perhaps using the security manager?

Thanks in advance,

Luis

Gaucho
  • 899
  • 1
  • 12
  • 25

1 Answers1

0

There are at least two ways I can think of you can do that outside of java and inside of java.

The outside of java way would be to use something like logrotate. This assumes that you are running on a *nix platform. logrotate allows you to specify which files are logs, how to long to keep them, when to roll them over to a new file, etc. It is highly configurable and probably already there.

The inside of java method would be to use log4j. The Tomcat URL that you already specified had the first steps to setting up log4j. As you can see from the configuration page it is extremely advanced. You can set up different loggers for different purposes and each one can have different files it would write to. log4j also has similar features as logrotate for the files it writes to.

Ultimately my recommendation would be to use log4j.

cogsmos
  • 806
  • 6
  • 11
  • Thanks cogsmos! Yes, I agree with you in the use of the good and classic log4j. But my problem is to find out how to control the logs of the web applications that are deployed by the users? – Gaucho May 16 '13 at 16:36
  • Do you have any control over how they are using the Logger.getLogger() ? – cogsmos May 17 '13 at 01:34
  • mmm, no, not really, but maybe I could override the users log4j.properties like here: http://stackoverflow.com/questions/4258849/override-log4j-properties – Gaucho May 17 '13 at 07:53