By default, Office SharePoint Server 2007 trace logging is enabled in Central Administration > Operations > Diagnostic Logging and the log files are stored at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS on your front-end web server.
Without changing the verbosity of logging via event throttling settings, or the number of minutes before creating a new log file, each log file is around 50 MB. By default, MOSS keeps 48 of these files, spanning 2 days for a grand total of around 2.4 GB.
I have changed the default path location to a different drive in the Trace Log section and decrease the number of log files to 12 to be used for 24hrs(1440 min).
Here are the settings on the diagnostic logging page:
The log file related to SharePoint_Config database can grow to huge sizes without a maintenance plan, or at the very least setting databases to backup in “simple” mode will dramatically reduce the size of the logs.
MOSS 2007 server installation has a log file called WSS_AdminService.log held in C:\Documents and Settings\Default User\Local Settings\Temp. This is just a log file and it is being written at regular intervals increasing its size. Worse still, because it’s in the C:\Documents and Settings\Default User folder it gets duplicated when a new user logs onto the server console. You can safely delete this file.
—————————————–
-
using System;
-
using System.Collections.Generic;
-
using System.Text;
-
using System.ComponentModel;
-
using System.Runtime.InteropServices;
-
namespace TemporaryFilesRemoval
-
{
-
class Program
-
{
-
/// <summary>
-
/// The main entry point for the application.
-
/// </summary>
-
[STAThread]
-
static void Main(string[] args)
-
{
-
Console.Title = “Temporary LOG Files Removal”;
-
DeleteFiles(“C:\\Program Files\\Common Files\\Microsoft Shared\\web server extensions\\12\\LOGS”, “*.log”);
-
DeleteFolder(“C:\\Program Files\\Common Files\\Microsoft Shared\\web server extensions\\12\\LOGS”, “*.log”);
-
DeleteFiles(“D:\\Sharepoint Logs”, “*.log”);
-
DeleteFiles(“C:\\Documents and Settings\\Default User\\Local Settings\\Temp”, “*.log”);
-
}
-
static void DeleteFolder(string rootfolder, string filter)
-
{
-
try
-
{
-
string[] directories = System.IO.Directory.GetDirectories(rootfolder);
-
Console.WriteLine(string.Format(“Total {0} directories in {1}”, (directories.Length), rootfolder));
-
foreach (string dir in directories)
-
{
-
DeleteFiles(dir, filter);
-
DeleteFolder(dir, filter);
-
try
-
{
-
Console.WriteLine(string.Format(“Deleting directory : {0}”, dir));
-
System.IO.Directory.Delete(dir);
-
Console.WriteLine(string.Format(“{0} has been deleted.”, dir));
-
}
-
catch (Exception ex)
-
{
-
Console.WriteLine(string.Format(“Error : {0}”, ex.Message));
-
Console.WriteLine();
-
}
-
}
-
}
-
catch (Exception ex)
-
{
-
Console.WriteLine(string.Format(“Error : {0}”, ex.Message));
-
Console.WriteLine();
-
}
-
}
-
static void DeleteFiles(string folder, string filter)
-
{
-
string[] files = null;
-
try
-
{
-
if (!string.IsNullOrEmpty(filter))
-
{
-
files = System.IO.Directory.GetFiles(folder, filter);
-
}
-
else
-
{
-
files = System.IO.Directory.GetFiles(folder);
-
}
-
Console.WriteLine(string.Format(“Total {0} file(s) in {1}”, (files.Length), folder));
-
Console.WriteLine();
-
foreach (string file in files)
-
{
-
Console.WriteLine(string.Format(“Deleting {0}”, file));
-
System.IO.File.Delete(file);
-
Console.WriteLine(string.Format(“{0} has been deleted.”, file));
-
Console.WriteLine();
-
}
-
}
-
catch (Exception ex)
-
{
-
Console.WriteLine(string.Format(“Error : {0}”, ex.Message));
-
Console.WriteLine();
-
}
-
}
-
}
-
}
—————————————–
I have included a word version of it here –LogClean or Alternatively http://technobuff.pastebin.com/f61f70e48
Please note that in the above code, I have also included my new path of trace logs i.e, (“D:\\Sharepoint Logs”, “*.log”);
You can also use the same application to clean up your Temporary ASP.NET Files. Just include the path, default will be C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
DeleteFiles(“C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files”, string.Empty);
DeleteFolder(“C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files”, string.Empty);