Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good size (in bytes) for a log file?

Tags:

python

logging

I am using the python logging modules RotatingFileHandler, and you can set the maximum size of each log file. What is a good maximum size for a log file? Please give your answer in bytes.

like image 356
Isaiah Avatar asked Oct 05 '09 16:10

Isaiah


People also ask

What is a good log file size?

A good STARTING POINT for your log file is twice the size of the largest index in your database, or 25% of the database size. Whichever is larger.

What is log maximum size?

The maximum log file size can be configured between 1 megabyte (1,024 kilobytes) and 4 terabytes (4,194,240 kilobytes) in kilobyte increments.

What is log files in big data?

Log files are the primary data source for network observability. A log file is a computer-generated data file that contains information about usage patterns, activities, and operations within an operating system, application, server or another device.


2 Answers

My default logging setup:

RotatingFileHandler(filename, maxBytes=10*1024*1024, backupCount=5) 
like image 191
codeape Avatar answered Oct 02 '22 19:10

codeape


As the other answers have said, there is a no hard and fast answer. It depends so much on your app and your environment. Here's some guidelines I use.

For a multi-user app on a typical server: Configure your logging to generate no more than 1 or 2 entries per user action for production, and then rotate it daily. Keep as many days as you have disk space for, or your data retention/privacy policies allow for. If you want auditing, you probably want a separate solution.

For a single-user app: Try and keep enough information to diagnose anything weird that might happen. No more than 2 or 3 entries per user action though, unless you are doing batch operations. Don't put more than 2MB in a file, so the user can email it you. Don't keep more than 50MB of logs, because it's probably not your space you are wasting here.

like image 40
Colin Pickard Avatar answered Oct 02 '22 18:10

Colin Pickard