Summary of .NET frameworks supported by log4net

log4net now builds on 5 frameworks. Each build has a different assembly name to identify which framework it targets:

Assembly Framework Website
log4net-net-1.0.dll Microsoft .Net Framework 1.0 (1.0.3705) http://msdn.microsoft.com/net
log4net-net-1.1.dll Microsoft .Net Framework 1.1 Final Beta (1.1.4322) http://msdn.microsoft.com/net
log4net-netcf-1.0.dll Microsoft .Net Compact Framework 1.0 (1.0.5000) http://msdn.microsoft.com/vstudio/device/compactfx.asp
log4net-mono-0.23.dll Mono 0.23 http://www.go-mono.org
log4net-sscli-1.0.dll Microsoft Shared Source CLI 1.0 http://msdn.microsoft.com/library/en-us/dndotnet/html/mssharsourcecli.asp

Appenders

The appenders available to each framework depend on the functionality of the framework and the platform it runs on:

Appender .NET Framework 1.0 .NET Framework 1.1 .NET Compact Framework 1.0 Mono 0.23 Shared Source CLI 1.0
ADONetAppender x x x x
ASPNetTraceAppender x x x
BufferingForwardingAppender x x x x x
ConsoleAppender x x x x x
CountingAppender x x x x x
EventLogAppender x x
FileAppender x x x x x
ForwardingAppender x x x x x
MemoryAppender x x x x x
NetSendAppender x x
OutputDebugStringAppender x x x
RemotingAppender x x x x
RollingFileAppender x x x x x
SMTPAppender x x x
TraceAppender x x x x x
UdpAppender x x x x x

Framework Specific Notes

Microsoft .Net Framework 1.0 (1.0.3705)

none

Microsoft .Net Framework 1.1 (1.1.4322)

none

Microsoft .Net Compact Framework 1.0 (1.0.5000)

  • Assembly attributes

    The .NET Compact Framework 1.0 does not support retrieving assembly-level attributes, therefore all log4net configuration attributes were removed from the .NET Compact Framwork 1.0 version of log4net.

    For Smart-device applications, the log4net system can be configured by passing the location of the log4net configuration file to the log4net.Config.DOMConfigurator.Configure(FileInfo) method in the entrypoint of the application.

    For example:

    namespace TestApp
    {
    	using System.IO;
    
    	public class EntryPoint
    	{
    		/// <summary>
    		/// Application entry point.
    		/// </summary>
    		public static void Main() 
    		{
    			// Uncomment the next line to enable log4net internal debugging
    			// log4net.helpers.LogLog.InternalDebugging = true;
    
    			// This will instruct log4net to look for a configuration file
    			// called config.log4net in the root directory of trhe device
    			log4net.Config.DOMConfigurator.Configure(new FileInfo(@"\config.log4net"));
    
    			...
    			
    			// This will shutdown the log4net system
    			log4net.LogManager.Shutdown();
    		}
    	}
    }						
    							
  • Notification events

    The .NET Compact Framework 1.0 does not support notification events during the application shutdown, therefore log4net cannot automaticaly hook the application shutdown notification.

    Applications will need to programatically shutdown the log4net system during the application's shutdown using the log4net.LogManager.Shutdown() method in order to prevent losing logging events. See the code above for an example.

  • FileSystemWatcher

    The .NET Compact Framework 1.0 does not support the System.IO.FileSystemWatcher class. As a result, the DOMConfiguratorAttribute.Watch property and the DOMConfigurator.ConfigureAndWatch methods are not available. Watching changes to the log4net configuration file is not supported on the .NET Compact Framework 1.0.

  • UserName

    The .NET Compact Framework 1.0 does not support the System.Security.Principal.WindowsIdentity class. This is used to capture the current thread's user identity. Therefore the LoggingEvent.UserName property will return the value "NOT AVAILABLE".

  • Environment variables

    The .NET Compact Framework 1.0 does not support retrieving environment variables, therefore it's not possibe to substitute environment variables in parameter values when using the .NET Compact Framework 1.0 version of log4net.

  • Serialization

    The .NET Compact Framework 1.0 does not support serialization, therefore none of the log4net classes in the .NET Compact Framework 1.0 version are serializable.

Mono 0.23

  • Reflection

    In Mono 0.23, the Type.GetProperty(string, BindingFlags) method does not support case-insensitive lookup of properties. This issue (Mono bug #38957) forces users to use the exact case for all dynamically bound elements in the log4net configuration file, these include:

    • Layout
    • Filter

    For example, instead of having the following section in the log4net configuration file:

    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
    	<layout type="log4net.Layout.PatternLayout">
    		<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
    	</layout>
    	<filter type="log4net.Filter.LevelRangeFilter">
    		<param name="LevelMin" value="DEBUG" />
    		<param name="LevelMax" value="INFO" />
    	</filter>
    </appender>					
    							

    You should use the following section (in a Mono 0.23 applications):

    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
    	<Layout type="log4net.Layout.PatternLayout">
    		<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
    	</Layout>
    	<Filter type="log4net.Filter.LevelRangeFilter">
    		<param name="LevelMin" value="DEBUG" />
    		<param name="LevelMax" value="INFO" />
    	</Filter>
    </appender>
    							

Microsoft Shared Source CLI 1.0

  • FileSystemWatcher

    SSCLI 1.0 does not support the System.IO.FileSystemWatcher class. As a result, the DOMConfiguratorAttribute.Watch property and the DOMConfigurator.ConfigureAndWatch methods are not available. Watching changes to the log4net configuration file is not supported on SSCLI 1.0.

  • UserName

    SSCLI 1.0 does not support the System.Security.Principal.WindowsIdentity class. This is used to capture the current thread's user identity. Therefore the LoggingEvent.UserName property will return the value "NOT AVAILABLE".