2014-09-16

svn:global-ignores

After struggling for some time in making sure that the svn:ignore property is applied recursively, I've recently realized that Subversion 1.8.x introduced the svn:global-ignores, which makes sure you just need to set a property in the root folder.
It uses the same values as svn:ignore, and will work mixed with it (values are appended). By the way, currently TortoiseSVN (v 1.8.7) doesn't work at 100% (not all folders and files are ignored in the first commit), but probably it will be fixed in the future.

2014-04-07

log4net: filtering by logger name with external libraries


When using third-party libraries and Common.Logging, if you are relying on the root logger, you might end up catching the log entries from the third-part library. While this might usefull when debugging, it might also be annoying, specially if the library is quite verbose. One of such libraries is Quartz.NET.

Luckily, log4net is flexible enough to allow us to redirect those entries to a different appender (or to turn them off completely) via the filter mechanism. My first approach was to add the following to all the appenders that I did not want to include Quartz log entries (notice that you must include the namespace for all the classes):

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Core.QuartzScheduler" />

        <acceptOnMatch value="false" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Core.SchedulerSignalerImpl" />

        <acceptOnMatch value="false" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Impl.AdoJobStore.JobStoreTX" />

        <acceptOnMatch value="false" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Impl.AdoJobStore.StdRowLockSemaphore" />

        <acceptOnMatch value="false" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Impl.StdSchedulerFactory" />

        <acceptOnMatch value="false" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin" />

        <acceptOnMatch value="false" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Util.DBConnectionManager" />

        <acceptOnMatch value="false" />

      </filter>

Then I added the following to a new appender in which I want to catch only the Quartz.NET log entries:

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Core.QuartzScheduler" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Core.SchedulerSignalerImpl" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Impl.AdoJobStore.JobStoreTX" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Impl.AdoJobStore.StdRowLockSemaphore" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Impl.StdSchedulerFactory" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin" />

      </filter>

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz.Util.DBConnectionManager" />

      </filter>

While this works, it seemed at little cumbersome to have to write all the classes that are appenders, so I investigated a little further and found out that you can use only a prefix of the namespace instead of the full class name, so you can just include the following in the appenders in which you want to remove (notice the final dot "." in the namespace):

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz." />

        <acceptOnMatch value="false" />

      </filter>

And the following in the appenders in you wish to include:

      <filter type="log4net.Filter.LoggerMatchFilter">

        <loggerToMatch value="Quartz." />

      </filter>


sources: beefy code tutorial and log4net documentation

Logging log4net

When logging doesn't work, you may need to log the log.

Basically, you have to add this to <appSettings>:

    <add key="log4net.Internal.Debug" value="true"/>

This should enable you to see some output on the console (or Visual Studio if you running an app from there). If this doesn't suit your needs, then writing to a file may be appropriate, by adding the following to the <system.diagnostics> section:

    <trace autoflush="true">
      <listeners>
        <add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\log4net.txt" />
      </listeners>
    </trace>


source: Stack Overflow and Apache log4net FAQ

2014-03-05

Maximum client concurrent HTTP connections to a web service

While performing some load testing on a web service (using Specflow), we've stumbled on a two concurrent connections limitation. Apparently, the limitation is in the HTTP/1.1 .NET client implementation, as described in here. Our solution was to set the ServicePointManager.DefaultConnectionLimit property  to the number of concurrent requests we want to test, just before creating the channel.

2014-03-04

How to know which SQL Server version and edition you are running

SELECT @@VERSION AS [Version]
Will return something like:
Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)   Apr  2 2010 15:48:46   Copyright (c) Microsoft Corporation  Express Edition with Advanced Services (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) 
Found it here.