X

Managing large log files taking up disk space

Sometimes problems with the handling of log files in OS X can result in log files taking up large amounts of disk space. Here are some ways to tackle these problems.

Topher Kessler MacFixIt Editor
Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.
Topher Kessler
5 min read

If you usually keep a known amount of hard-drive space clear, and suddenly find your system running low on space, a problem with the way the system handles log files may be to blame. You can use a tool like DaisyDisk or GrandPerspective to check the relative file sizes on disk, and if the problem is because of large log files then you may see these programs report one or two files using a large proportion of the hard drive. Many times a random increase in disk usage can be attributed to a problem with OS X's log management system.

Apple's log manager in OS X is an API called "Apple System Log" (asl) which can be used by developers to easily implement log handling in their programs. This can be useful for tracking odd program behavior or system access events, but for the most part log messages go unused (especially on consumer systems). Generally log files are only a couple of megabytes in size at most (and then are archived in a compressed file after a period of time) which allows them to be better managed; however, sometimes problems can occur in the handling of log files where they can end up being continually written to, and as a result get very large.

Luckily log files have no play in the performance of the system, and are written to as a byproduct of application function instead of being a requirement for it. If a log file is missing then applications or system services may warn you of it, but usually do not have any problems functioning. Instead, missing log files are generally just recreated by a program if needed. Because of this, if your system is showing problems with handling certain log files, then you can just delete them without harming the computer at all.

In essence deleting a log file is like a cashier ripping off a long paper tape from a receipt printer at a checkout counter. If the paper printout is left attached, then it will roll all over the place and get in the way; however, if it is removed, then the printer will still function, but will do so without as much of a mess for the cashier.

There are several ways to remove log files in OS X, including using the Finder, the Console utility, or third-party maintenance tools.

  1. Finder

    If you choose to use the Finder, you will need to access the system log directory which is one of the hidden system directories. To do this, choose "Go to folder" from the Go menu and then enter "/private/var/log" in the field. This will open the hidden log folder, from where you can browse the log files and delete the large ones. To help isolate large log files you can use the Finder window to sort items by size or get information on specific files of interest.

  2. Console

    You can also use the Console utility (located in the /Applications/Utilities/ folder) to manage log files, since it will allow you to conveniently browse and display your logs. Unfortunately the Console utility will not tell you the size of the log file itself, but if you already know which one you want to remove, then you can locate and highlight it in the Console, and then press Command-R to remove it (or right-click it and delete it that way).

    If you decide to use the Console, you can also try reading the log file to see if there are any tell-tale signs of why it became so large. Sometimes this can happen because a program has written to the file over and over, but it could also be because of file corruption that is not apparent by reading the file (it may also make the file impossible to read).

  3. Maintenance tools

    In our general maintenance recommendations for OS X we have a list of common maintenance tools, each of which can be used to clear log files on the system. If you have a maintenance tool installed, you can always launch it to remove log files.

While removing a problematic log file will clear the problem, especially if corruption in the file itself was the root of the problem, it may not necessarily fix the problem if a program or system service is not writing or managing log files correctly. Nevertheless it will be a temporary and necessary step to regain your lost hard-drive space. If the problem does persist beyond deleting log files, then you can try addressing how various system services and applications are running on the system.

The first thing to do if the problem returns is to restart the computer, and preferibly restart into Safe Mode (hold Shift at bootup) after which you can then restart again normally. This will perform some basic maintenance routines on the system and reload all system services, which in itself may fix the problem. Additionally you can try running a general maintenance routine on the system to perform a more in-depth cleaning of the OS.

As part of a maintenance routine you can also try targeting the preferences files for programs you suspect are responsible for the log problems. Locate the preference files in the /username/Library/Preferences/ folder that are associated with the program (they should be named by the convention "domain.developer.programname.plist") and remove it. Then relaunch the program and see if the problem continues.

Beyond running maintenance routines, you can try disabling various system services and features. Start by going to the Sharing system preferences and unchecking various sharing services, followed by disabling features like Time Machine, Bluetooth, Wi-Fi, and any others you may have enabled in the system preferences. You should also troubleshoot by unplugging any peripheral devices from the system, as these can cause the kernel and other low-level system processes to output connection and use details as well as problems to various log files. After doing this, monitor the log files to see if any start getting large again.

Lastly, if the problem persists you can try reinstalling aspects of your system. Try reapplying the latest "Combo" updater for your installed version of OS X, to see if that helps clear any underlying OS configuration problems that could be contributing to the log errors. To do this, go to the Apple Support Downloads page and search for your version of OS X followed by the word "Combo" (i.e., "OS X 10.5.8 Combo"). Download and run the updater, and then restart the system when prompted. In addition to reapplying combo updaters, you can also try reinstalling various third-party applications associated with the problematic log files.



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.