Very heavy Tomcat log

Asked

Viewed 1,232 times

3

I have noticed that some files that get inside the folder Log of Tomcat are getting too heavy. Yesterday I deleted a file with 40GB and today already has another with 2GB.

I can’t read the contents of these files because they’re too big.

  • How are these Logs generated? Does my system look bad configured?

  • Is there any way to disable or limit the size of these files?

This is the file that is with 2GB at the moment: tomcat8-stdout.

  • What level is set for logs in conf/logging.properties ?

  • The level for some properties is INFO

1 answer

2


There are several possible reasons, which usually mix. The most common are:

  • Independent log levels. It may be that the general log is INFO, but for some classes or applications is different. Check log settings in Tomcat and also in the applications that are running.

  • Writing to more than one place. Applications may be redirecting logs to the stdout instead of individual files, or who knows even for both places.

  • Applications writing directly to stdout. Poorly made systems or with inattentive programmers may have in the code some System.out.println and e.printStackTrace which was left there for debugging during development, but which now has no way of being shut down. To make matters worse, they sometimes put it into bonds.

  • Many applications running on the same server. The more systems, the more logs. However, they should write to different files.

  • Many accesses to the server. The more accesses, the more logs. Check if there was no access spike or if the number of users is not above server capacity.

Considerations

By file size, I’d say there are some classes logging in with DEBUG or TRACE or that all queries to the database are written.

Inevitably you will need to look at the logs to understand what is occurring. Of course it will not be possible to use a traditional text editor, so use another tool to partially load the file or to extract part of the file to another one. If you use Linux or Mac will be easy, if it is with Windows will suffer a little, but it is possible.

Finally, configure rotary log specifying a maximum size for the file. Thus you avoid a lot of headache and can still archive the logs routinely. Just be careful when discarding old logs too early, you may need them for auditing, detecting fraud or investigating obscure bugs.

  • 1

    Remembering that you don’t even need to discard the rotations, you can compress on the server, and periodically move to a local file, clearing the server.

  • 1

    Thanks for the answer, I think I know what’s going on, I forgot turned on the Hibernate property that prints the SQL code to each operation. I will disable this property.

  • @Techies makes perfect sense. Hopefully that’s all.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.