Sql-server – How to clean up database log file automatically to prevent errors

databasesql server

I host website and sometimes get an error: The log file for database '%.*ls' is full. and have to contact my hosting provider for cleaning database log file.

How I can disable logging or configure it to be sure that log file will not fill up?

(I am using Community Server engine so sql optimization must not be done.)

Best Answer

The log file is dependent on the database recovery model. The default is Full which means you'll be doing backups of the database and transaction log. When you backup the transaction log, it will truncate. If you never backup the transaction log, it will grow forever. If you only want to backup the full database, then change the recovery model to simple.

Once this is changed you'll want to shrink the log files (right-click database in sql management studio, Tasks > Shrink > Files). You can set them to auto-shrink but once you've fixed the underlying recovery model problem you may not need to.