SharePoint Blog - René Hézser

Anmelden  RSS Feed RSS Feed
Startet die Suche

Archive

Kategorien

Links

Andere Blogs



Add to Technorati Favorites

Mar 222010

Modify Overwrite Policy for an EventLog created by an EventLogInstaller

Developing a Windows Service is a common task. Creating an EventLog for this service also is a common practice. The EventLog can be created with a ServiceInstaller (a class which inherits from System.Configuration.Install.Installer).

This is how an Eventlog can be added during the installation with a custom Installer class:

public Installer()
   {
      Installers.Add(new EventLogInstaller
               {
                  Source = "EventLogSource",
                  Log = "EventLogName"
               });

The EventLogInstaller class does not allow to set the overwrite mode.

You can change the overwrite mode after the log has been created, if you use the Committed Event.

public Installer()
{
   ...
   Committed += OnCommitted;
}

/// <summary>
/// modify the eventlog
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void OnCommitted(object sender, InstallEventArgs e)
{
   EventLog log = EventLog.GetEventLogs().SingleOrDefault(l => l.Log == "EventLogName");
   if (log == null) throw new InvalidOperationException("The log does not exist");
   log.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, 30);
}

Published: 3/22/2010  2:13 PM | 0  Comments | 0  Links to this post
Tagged as: Development

Mar 072010

2010 RTM date

2010? Which 2010?

Office and SharePoint. They will reach RTM status in April. Availability is May 12th and June for “regular customers”.

http://www.microsoft.de/2010launch

Source: RTM- und Launch-Termin, Technologiegarantie


Published: 3/7/2010  12:39 AM | 0  Comments | 0  Links to this post
Tagged as: SharePoint

Mar 042010

PDF iFilter Comparison

Crawling PDF files can be a long running process with the Adobe PDF iFilter. We already knew that.

Jie Li compared 3 iFilters for indexing PDF files.

To make it short, the Adobe iFilter takes roughly about 33 times the time compared to the Foxit iFilter 2 on that particular server.

See all details…


Published: 3/4/2010  10:51 AM | 0  Comments | 0  Links to this post
Tagged as: SharePoint

Mar 032010

Shrink SQL log files

Depending on the configuration of you databases, the log files (*.ldf) can be very large. See Selecting a Recovery Model.

Should I continue reading?

If your databases are configured to use the FULL recovery model, the log files are very large and you need some free space, you can use this SQL script to shrink them. So keep on reading :-)

The script will change the recovery model for a single database to SIMPLE and shrink the log files. At the end it will restore the recovery model to the setting it has been before.

Just copy the script to a new Query window in your SQL Management Studio. Replace the @databaseName and run the script by hitting F5. You can also change the size in MB the log file should be shrunken to.

USE [master]
GO
DECLARE @debug int
DECLARE @databaseName nvarchar(255)
DECLARE @logfile nvarchar(255)
DECLARE @newFileSize nvarchar(5) -- in MB
DECLARE @sql nvarchar(4000)
DECLARE @parmDefinition nvarchar(500)
DECLARE @recoveryModel nvarchar(10)

--
-- CHANGE HERE BEGIN
set @debug = 1
set @newFileSize = 100 -- in MB
set @databaseName = 'your database name'
-- CHANGE HERE END
--

IF @debug = 1 PRINT 'DatabaseName=' + @databaseName

-- get recovery model from database
SET @sql = N'SELECT @model = recovery_model_desc FROM sys.databases WHERE [name]=''' + @databaseName +''''
SET @ParmDefinition = N'@model nvarchar(255) OUTPUT';
EXECUTE sp_executesql @sql, @ParmDefinition, @model = @recoveryModel OUTPUT;
if @debug = 1 PRINT 'Recovery model=' + @recoveryModel

-- set recovery modell to simple
SELECT @sql = 'ALTER DATABASE [' + @databaseName + '] SET RECOVERY SIMPLE'
IF @debug = 1 PRINT @sql
EXECUTE sp_executesql @sql

-- shrink log file
-- get logfile from database
SET @sql = N'USE [' + @databaseName + ']; SELECT @logfileName = [name] FROM sys.database_files WHERE [type_desc]=''LOG'''
SET @parmDefinition = N'@logfileName nvarchar(255) OUTPUT';
EXECUTE sp_executesql @sql, @parmDefinition, @logfileName = @logFile OUTPUT;
if @debug = 1 PRINT 'Logfile Name=' + @logfile

SELECT @sql = 'USE [' + @databaseName + ']; DBCC SHRINKFILE ([' + @logfile + '] , ' + @newFileSize + ')'
IF @debug = 1 PRINT @sql
EXECUTE sp_executesql @sql

-- restore recovery modell
SELECT @sql = 'ALTER DATABASE [' + @databaseName + '] SET RECOVERY ' + @recoveryModel + ''
IF @debug = 1 PRINT @sql
EXECUTE sp_executesql @sql

-- done

Published: 3/3/2010  11:16 AM | 1  Comment | 0  Links to this post
Tagged as: SQL Server