Log4Net 1.2.9 Beta released

Following the many discussions of log4net vs Enterprise Library Logging has convinced me to give log4net another chance.  Log4Net 1.2.9 Beta has just been released after 20 months or so since a release.
You can download it here at Log4Net’s download page

 Here are the release notes if you are interested:

1.2.9 Beta

Breaking Changes

  • Renamed namespaces

    Renamed namespace log4net.spi to log4net.Core. Renamed namespace log4net.helpers to log4net.Util.

  • Renamed config classes and attributes

    In the log4net.Config namespace the DOMConfigurator, DOMConfiguratorAttribute, DomainAttribute, and AliasDomainAttribute have been marked as obsolete. These types are still available and functional in this release.

    The XmlConfigurator and XmlConfiguratorAttribute types replace DOMConfigurator and DOMConfiguratorAttribute. The RepositoryAttribute and AliasRepositoryAttribute types replace DomainAttribute and AliasDomainAttribute.

  • Fixed pascal casing of type names

    Renamed AdoNetAppender, AspNetTraceAppender, SmtpAppender, Iso8601DateFormatter, MdcFilter, and NdcFilter. Note that the config file type resolver is case insensitive so this is only a breaking change for code that programmatically creates a type that has been renamed.

  • Layouts changed to stream their output to a TextWriter

    Layouts have been changed to format their output to a TextWriter rather than return a string. This increases performance and reduces temporary object creation.

  • C style string escapes no longer supported by config parser

    The XML config parser no longer supports decoding C style escape sequences in strings. Previously sequences like \n and \\ where decoded. Instead use the appropriate XML encodings as required.

New Features

  • New CLI build

    A new log4net assembly is built that targets all CLI 1.0 compatible runtimes. This build is essentially a common subset of the Mono 1.0 and .NET 1.0 builds. It is built using the MS .NET 1.0 compiler and libraries but does not use any platform specific APIs.

    This build is only available in release configuration and can be found at bin\cli\1.0\release.

  • Logging contexts

    Logging contexts can be used to record contextual data that is relevant to the current process. Logging contexts are both an extension of the concepts embodied in the MDC and NDC and a replacement for them. The MDC and NDC have been reimplemented to use the ThreadContext as storage.

    The logging contexts provide a single unified view that cuts across different scopes within an application. The contexts are layered in the following order of narrowing scope: GlobalContext, ThreadContext, LogicalThreadContext, and LoggingEvent. Context values specified in a narrower scope hide the matching value in a wider scope.

  • PatternLayout customization and long pattern names

    The PatternLayout now supports long pattern names. These pattern names are significantly more readable than the single character patterns.

    The PatternLayout now supports custom patterns. New patterns can be defined in the config file:

    <layout type="log4net.Layout.PatternLayout">  <converter>    <name value="myConverter" />    <type value="TestApp.MyPatternConverter, TestApp" />  </converter>  <conversionPattern value="%-5level %logger - %myConverter - %message%newline" /></layout>

    The above config defines a custom pattern called myConverter which is bound to the TestApp.MyPatternConverter, TestApp type. This type must extend the log4net.Util.PatternConverter base class. The custom pattern can then be used in the pattern string.

    For full details see the SDK Reference entry: log4net.Layout.PatternLayout.

  • PatternString for pattern based configuration

    A new pattern based type, PatternString, can be used in the config file to set string properties using a pattern syntax. For example the File property of the FileAppender could be set as follows:

    <file type="log4net.Util.PatternString">  <converter>    <name value="folder" />    <type value="TestApp.SpecialFolderPatternConverter,TestApp" />  </converter>  <conversionPattern value="%folder{LocalApplicationData}\log-file.txt" /></file>

    The code for the SpecialFolderPatternConverter is as follows:

    public class SpecialFolderPatternConverter : log4net.Util.PatternConverter {  override protected void Convert(System.IO.TextWriter writer, object state)   {    Environment.SpecialFolder specialFolder =       (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), base.Option, true);          writer.Write(Environment.GetFolderPath(specialFolder));  }}

    For full details see the SDK Reference entry: log4net.Util.PatternString.

  • Loading configuration from a URI

    The XmlConfigurator methods now support loading the configuration data from a URI. Config can be loaded from any URI supported by the System.Net.WebRequest class.

  • Support for No-Touch deployment

    Log4net supports configuring No-Touch deployment applications using the XmlConfiguratorAttribute. If a relative config file or extension is specified then this is resolved relative to the deployment URI.

  • Config file parser enhancements

    The config file parser has been enhanced to support specifying the property subtype, or intermediate type, directly on the property element, for example:

    <layout type="log4net.Layout.PatternLayout" value="%message%newline" />

    Implicit conversion will be attempted between the value string and the type specified, and then again between the type and the target property type.

  • .NET string formatting syntax

    Added .NET String.Format style formatting syntax methods to the ILog interface. The new methods are: DebugFormat, InfoFormat, WarnFormat, ErrorFormat and FatalFormat.

  • Customizable levels

    Levels are defined by the repository LevelMap. The defined levels, the relative ordering of levels and level display names can be configured on a per-repository basis.

  • Per-appender security contexts

    Appenders that interact with controlled platform resources, e.g. files, can be configured to use a separate security context when accessing these resources. The calling thread may not have appropriate privileges to access the resource a custom SecurityContext can be used to elevate the privileges of the appender. The WindowsSecurityContext is used to specify alternative credentials on the Windows platform.

  • Added new appenders

    AnsiColorTerminalAppender

    The AnsiColorTerminalAppender writes events to the application's ANSI terminal window. It can be configured to specify the text and background colors for different level events. Note that Console applications running on Windows do not have an ANSI terminal window and should use the ColoredConsoleAppender instead.

    LocalSyslogAppender

    Logs events to a local syslog service. This appender uses the POSIX libc syslog library functions. If these functions are not available on the local system then this appender will not work!

    RemoteSyslogAppender

    The RemoteSyslogAppender uses the BSD syslog protocol to log to a syslog daemon. The syslogd listens for for messages on UDP port 514.

    TelnetAppender

    The TelnetAppender accepts socket connections and streams logging messages back to the client. The output is provided in a telnet-friendly way so that a log can be monitored over a TCP/IP socket. This allows simple remote monitoring of application logging.

  • Added new LoggerMatchFilter filter

    Added LoggerMatchFilter which matches a string against the event's logger name.

  • Pluggable file locking models for the FileAppender

    The FileAppender (and by extension the RollingFileAppender) now support pluggable file locking models. The default model, ExclusiveLock, maintains the current exclusive file locking behavior. An alternative model, MinimalLock, can be used to support writing to a single output file from multiple processes.

    For full details see the SDK Reference entry: log4net.Appender.FileAppender.LockingModel.

  • RollingFileAppender roll once

    The RollingFileAppender now supports a new rolling style, Once. In this mode the appender will roll the file once per run.

  • SmtpAppender authentication

    On the .NET 1.1 platform only, the SmtpAppender supports authenticating against the mail server using either username and password or integrated NTLM authentication.

  • AdoNetAppender ReconnectOnError

    Added new configuration property to AdoNetAppender. Setting ReconnectOnError to true will force the appender to attempt to reconnect to the database if the connection is lost.

  • UdpAppender hostname support

    The UdpAppender config property RemoteAddress can now be specified as a DNS hostname string. The hostname is resolved to an IP address.

Other Changes

  • FxCop compliance

    Updates to bring the internal code in line with the current FxCop rules.

  • Separate NUnit tests

    Moved the NUnit tests into a separate project, log4net.Tests.

  • Bug Fixes

    RemotingAppender

    Sends events from a ThreadPool thread rather than the calling thread to prevent transfer, and potential loss, of the CallContext.

    RollingFileAppender

    Fixed date rolling period detection for non UTC timezones.

    ColoredConsoleAppender

    Updated to support writing more than 30,000 chars in a single message. Fixed background color overspill if the console window needs to scroll the contents.

 

Recent Posts

Tag Cloud

1 Comment

Comments have been disabled for this content.