Skip to content
Browse files

Added a new specialized project to address issues with log4net 1.2.10

  • Loading branch information...
1 parent a542932 commit 73be576287a1614cf3191cb5b4e68b75258c99a9 @alexandrerocco committed May 8, 2012
View
BIN lib/log4net.1.2.10.dll
Binary file not shown.
View
65 src/ServiceStack.Logging.Log4Netv1210/Log4NetFactory.cs
@@ -0,0 +1,65 @@
+using System;
+using System.IO;
+
+namespace ServiceStack.Logging.Log4Net
+{
+ /// <summary>
+ /// ILogFactory that creates an Log4Net ILog logger
+ /// </summary>
+ public class Log4NetFactory : ILogFactory
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Log4NetFactory"/> class.
+ /// </summary>
+ public Log4NetFactory() : this(false) { }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Log4NetFactory"/> class.
+ /// </summary>
+ /// <param name="configureLog4Net">if set to <c>true</c> [will use the xml definition in App.Config to configure log4 net].</param>
+ public Log4NetFactory(bool configureLog4Net)
+ {
+ if (configureLog4Net)
+ {
+ log4net.Config.XmlConfigurator.Configure();
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Log4NetFactory"/> class.
+ /// </summary>
+ /// <param name="log4NetConfigurationFile">The log4 net configuration file to load and watch. If not found configures from App.Config.</param>
+ public Log4NetFactory(string log4NetConfigurationFile)
+ {
+ //Restart logging if necessary
+ log4net.Repository.ILoggerRepository rootRepository = log4net.LogManager.GetRepository();
+ if (rootRepository != null)
+ rootRepository.Shutdown();
+
+ if (File.Exists(log4NetConfigurationFile))
+ log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(log4NetConfigurationFile));
+ else
+ log4net.Config.XmlConfigurator.Configure();
+ }
+
+ /// <summary>
+ /// Gets the logger.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <returns></returns>
+ public ILog GetLogger(Type type)
+ {
+ return new Log4NetLogger(type);
+ }
+
+ /// <summary>
+ /// Gets the logger.
+ /// </summary>
+ /// <param name="typeName">Name of the type.</param>
+ /// <returns></returns>
+ public ILog GetLogger(string typeName)
+ {
+ return new Log4NetLogger(typeName);
+ }
+ }
+}
View
188 src/ServiceStack.Logging.Log4Netv1210/Log4NetLogger.cs
@@ -0,0 +1,188 @@
+using System;
+
+namespace ServiceStack.Logging.Log4Net
+{
+ /// <summary>
+ /// Wrapper over the log4net.1.2.10 and above logger
+ /// </summary>
+ public class Log4NetLogger : ILog
+ {
+ private readonly log4net.ILog _log;
+
+ public Log4NetLogger(string typeName)
+ {
+ _log = log4net.LogManager.GetLogger(typeName);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Log4NetLogger"/> class.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ public Log4NetLogger(Type type)
+ {
+ _log = log4net.LogManager.GetLogger(type);
+ }
+
+ public bool IsDebugEnabled { get { return _log.IsDebugEnabled; } }
+
+ /// <summary>
+ /// Logs a Debug message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ public void Debug(object message)
+ {
+ if (_log.IsDebugEnabled)
+ _log.Debug(message);
+ }
+
+ /// <summary>
+ /// Logs a Debug message and exception.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="exception">The exception.</param>
+ public void Debug(object message, Exception exception)
+ {
+ if (_log.IsDebugEnabled)
+ _log.Debug(message, exception);
+ }
+
+ /// <summary>
+ /// Logs a Debug format message.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="args">The args.</param>
+ public void DebugFormat(string format, params object[] args)
+ {
+ if (_log.IsDebugEnabled)
+ _log.DebugFormat(format, args);
+ }
+
+ /// <summary>
+ /// Logs a Error message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ public void Error(object message)
+ {
+ if (_log.IsErrorEnabled)
+ _log.Error(message);
+ }
+
+ /// <summary>
+ /// Logs a Error message and exception.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="exception">The exception.</param>
+ public void Error(object message, Exception exception)
+ {
+ if (_log.IsErrorEnabled)
+ _log.Error(message, exception);
+ }
+
+ /// <summary>
+ /// Logs a Error format message.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="args">The args.</param>
+ public void ErrorFormat(string format, params object[] args)
+ {
+ if (_log.IsErrorEnabled)
+ _log.ErrorFormat(format, args);
+ }
+
+ /// <summary>
+ /// Logs a Fatal message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ public void Fatal(object message)
+ {
+ if (_log.IsFatalEnabled)
+ _log.Fatal(message);
+ }
+
+ /// <summary>
+ /// Logs a Fatal message and exception.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="exception">The exception.</param>
+ public void Fatal(object message, Exception exception)
+ {
+ if (_log.IsFatalEnabled)
+ _log.Fatal(message, exception);
+ }
+
+ /// <summary>
+ /// Logs a Error format message.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="args">The args.</param>
+ public void FatalFormat(string format, params object[] args)
+ {
+ if (_log.IsFatalEnabled)
+ _log.FatalFormat(format, args);
+ }
+
+ /// <summary>
+ /// Logs an Info message and exception.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ public void Info(object message)
+ {
+ if (_log.IsInfoEnabled)
+ _log.Info(message);
+ }
+
+ /// <summary>
+ /// Logs an Info message and exception.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="exception">The exception.</param>
+ public void Info(object message, Exception exception)
+ {
+ if (_log.IsInfoEnabled)
+ _log.Info(message, exception);
+ }
+
+ /// <summary>
+ /// Logs an Info format message.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="args">The args.</param>
+ public void InfoFormat(string format, params object[] args)
+ {
+ if (_log.IsInfoEnabled)
+ _log.InfoFormat(format, args);
+ }
+
+ /// <summary>
+ /// Logs a Warning message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ public void Warn(object message)
+ {
+ if (_log.IsWarnEnabled)
+ _log.Warn(message);
+ }
+
+ /// <summary>
+ /// Logs a Warning message and exception.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="exception">The exception.</param>
+ public void Warn(object message, Exception exception)
+ {
+ if (_log.IsWarnEnabled)
+ _log.Warn(message, exception);
+ }
+
+ /// <summary>
+ /// Logs a Warning format message.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="args">The args.</param>
+ public void WarnFormat(string format, params object[] args)
+ {
+ if (_log.IsWarnEnabled)
+ _log.WarnFormat(format, args);
+ }
+ }
+}
View
40 src/ServiceStack.Logging.Log4Netv1210/Properties/AssemblyInfo.cs
@@ -0,0 +1,40 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ServiceStack.Logging.Log4Net")]
+[assembly: AssemblyDescription(@"Provides log4net logging integration for other ServiceStack projects
+ Includes:
+ - ServiceStack.Logging.Log4Net.dll
+ Dependencies:
+ - ServiceStack.Interfaces.dll")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Demis Bellot")]
+[assembly: AssemblyProduct("ServiceStack.Logging.Log4Net")]
+[assembly: AssemblyCopyright("Copyright © ServiceStack 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("d575bdba-a6db-464c-8c41-bd0694b79b02")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.3")]
+[assembly: AssemblyFileVersion("1.0.3")]
View
23 src/ServiceStack.Logging.Log4Netv1210/ServiceStack.Logging.Log4Net.nuspec
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <id>$id$</id>
+ <version>$version$</version>
+ <title>$title$</title>
+ <authors>$author$</authors>
+ <owners>$author$</owners>
+ <summary>log4Net 1.2.10 logging integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework</summary>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>$description$</description>
+ <projectUrl>https://github.com/ServiceStack/ServiceStack.Logging</projectUrl>
+ <licenseUrl>https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE</licenseUrl>
+ <iconUrl>http://www.servicestack.net/logo-100x100.png</iconUrl>
+ <tags>servicestack log logging log4net</tags>
+ <language>en-US</language>
+ <copyright>servicestack.net 2012 and contributors</copyright>
+ <dependencies>
+ <dependency id="log4net" version="1.2.10" />
+ <dependency id="ServiceStack.Common" />
+ </dependencies>
+ </metadata>
+</package>
View
130 src/ServiceStack.Logging.Log4Netv1210/ServiceStack.Logging.Log4Netv1210.csproj
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{6A5E3F1C-5F68-4228-805C-2F2374DCC5C0}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ServiceStack.Logging.Log4Net</RootNamespace>
+ <AssemblyName>ServiceStack.Logging.Log4Netv1210</AssemblyName>
+ <SccProjectName>
+ </SccProjectName>
+ <SccLocalPath>
+ </SccLocalPath>
+ <SccAuxPath>
+ </SccAuxPath>
+ <SccProvider>
+ </SccProvider>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\src\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=1b44e1d426115821">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\log4net.1.2.10.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Common, Version=1.0.4425.9237, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\ServiceStack.Common.3.4.8\lib\ServiceStack.Common.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Interfaces, Version=1.0.4425.9237, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\ServiceStack.Common.3.4.8\lib\ServiceStack.Interfaces.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Text, Version=3.4.8.9213, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\ServiceStack.Text.3.4.9\lib\ServiceStack.Text.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Log4NetFactory.cs" />
+ <Compile Include="Log4NetLogger.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ <None Include="ServiceStack.Logging.Log4Net.nuspec" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
6 src/ServiceStack.Logging.Log4Netv1210/packages.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="log4net" version="1.2.11" />
+ <package id="ServiceStack.Common" version="3.4.8" />
+ <package id="ServiceStack.Text" version="3.4.9" />
+</packages>
View
6 src/ServiceStack.Logging.sln
@@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CA7CF5
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Logging.Log4Netv1210", "ServiceStack.Logging.Log4Netv1210\ServiceStack.Logging.Log4Netv1210.csproj", "{6A5E3F1C-5F68-4228-805C-2F2374DCC5C0}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -49,6 +51,10 @@ Global
{EE43BF1E-CF97-4215-A5A3-46D1C363F928}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE43BF1E-CF97-4215-A5A3-46D1C363F928}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE43BF1E-CF97-4215-A5A3-46D1C363F928}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6A5E3F1C-5F68-4228-805C-2F2374DCC5C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6A5E3F1C-5F68-4228-805C-2F2374DCC5C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6A5E3F1C-5F68-4228-805C-2F2374DCC5C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6A5E3F1C-5F68-4228-805C-2F2374DCC5C0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

0 comments on commit 73be576

Please sign in to comment.
Something went wrong with that request. Please try again.