Permalink
Browse files

Removed the log4net dependency and made the logging configurable.

- Separate project configs for building without log4net
- Logging functionality is factored into an ILog + ILogFactory interface
- New logger can be installed in the app.config or programmatically using the LogManager class
- See the *Adapter projects' Demo.config about including your favorite logger (log4net and NLog)
  • Loading branch information...
enyim committed Oct 18, 2010
1 parent 3a7bfee commit 8673380ac3d2f5f46013c06ddf5fd26b2bb49a83
Showing with 18,395 additions and 524 deletions.
  1. 0 CHANGES
  2. +29 −0 CommonProperties.targets
  3. +3 −68 DemoApp/DemoApp.csproj
  4. +33 −0 Enyim.Caching.Log4NetAdapter/Demo.config
  5. +58 −0 Enyim.Caching.Log4NetAdapter/Enyim.Caching.Log4NetAdapter.csproj
  6. +40 −0 Enyim.Caching.Log4NetAdapter/Log4NetFactory.cs
  7. +238 −0 Enyim.Caching.Log4NetAdapter/Log4NetWrapper.cs
  8. +37 −0 Enyim.Caching.Log4NetAdapter/Properties/AssemblyInfo.cs
  9. +15 −0 Enyim.Caching.NLogAdapter/Demo.config
  10. +59 −0 Enyim.Caching.NLogAdapter/Enyim.Caching.NLogAdapter.csproj
  11. +27 −0 Enyim.Caching.NLogAdapter/NLogFactory.cs
  12. +218 −0 Enyim.Caching.NLogAdapter/NLogWrapper.cs
  13. +36 −0 Enyim.Caching.NLogAdapter/Properties/AssemblyInfo.cs
  14. +13 −1 Enyim.Caching.sln
  15. +21 −0 Enyim.Caching/Configuration/LoggerSection.cs
  16. +11 −77 Enyim.Caching/Enyim.Caching.csproj
  17. +77 −0 Enyim.Caching/Logging/ILog.cs
  18. +33 −0 Enyim.Caching/Logging/ILogFactory.cs
  19. +101 −0 Enyim.Caching/Logging/LogManager.cs
  20. +116 −0 Enyim.Caching/Logging/NullLog.cs
  21. +1 −1 Enyim.Caching/Memcached/DefaultServerPool.cs
  22. +2 −2 Enyim.Caching/Memcached/MemcachedNode.cs
  23. +2 −2 Enyim.Caching/Memcached/PooledSocket.cs
  24. +1 −1 Enyim.Caching/Memcached/Protocol/Binary/BinaryNode.cs
  25. +1 −2 Enyim.Caching/Memcached/Protocol/Binary/BinaryRequest.cs
  26. +1 −1 Enyim.Caching/Memcached/Protocol/Binary/BinaryResponse.cs
  27. +1 −1 Enyim.Caching/Memcached/Protocol/Binary/DeleteOperation.cs
  28. +1 −1 Enyim.Caching/Memcached/Protocol/Binary/GetOperation.cs
  29. +1 −1 Enyim.Caching/Memcached/Protocol/Binary/MultiGetOperation.cs
  30. +1 −1 Enyim.Caching/Memcached/Protocol/Binary/StatsOperation.cs
  31. +1 −1 Enyim.Caching/Memcached/Protocol/Binary/StoreOperation.cs
  32. +1 −1 Enyim.Caching/Memcached/Protocol/Operation.cs
  33. +1 −1 Enyim.Caching/Memcached/Protocol/Text/GetHelper.cs
  34. +1 −1 Enyim.Caching/Memcached/Protocol/Text/MultiGetOperation.cs
  35. +1 −1 Enyim.Caching/Memcached/Protocol/Text/StatsOperation.cs
  36. +1 −1 Enyim.Caching/Memcached/Protocol/Text/TextSocketHelper.cs
  37. +1 −1 Enyim.Caching/Memcached/ServerStats.cs
  38. +1 −1 Enyim.Caching/MemcachedClient.cs
  39. +1 −10 Enyim.Caching/Properties/AssemblyInfo.cs
  40. +1 −1 Membase/BucketConfigListener.cs
  41. +1 −1 Membase/ConfigHelper.cs
  42. +2 −69 Membase/Membase.csproj
  43. +1 −1 Membase/MembaseClient.cs
  44. +1 −1 Membase/MembasePool.cs
  45. +2 −2 Membase/MessageStreamListener.cs
  46. +0 −9 Membase/Properties/AssemblyInfo.cs
  47. +6 −6 Membase/VBucketAwareOperationFactory.cs
  48. +2 −0 MemcachedTest/MembaseClientTest.cs
  49. +3 −1 MemcachedTest/MemcachedClientTest.cs
  50. +7 −51 MemcachedTest/MemcachedTest.csproj
  51. +2 −0 TestApp/App.config
  52. +36 −31 TestApp/Program.cs
  53. +7 −72 TestApp/TestApp.csproj
  54. +46 −22 VersionInfo.targets
  55. BIN binaries/NLog2/NLog.Extended.dll
  56. BIN binaries/NLog2/NLog.Extended.pdb
  57. +432 −0 binaries/NLog2/NLog.Extended.xml
  58. BIN binaries/NLog2/NLog.dll
  59. +2,560 −0 binaries/NLog2/NLog.netfx35.xsd
  60. BIN binaries/NLog2/NLog.pdb
  61. +14,031 −0 binaries/NLog2/NLog.xml
  62. BIN binaries/{ → log4net}/log4net.dll
  63. 0 binaries/{ → log4net}/log4net.xml
  64. +0 −79 build-release.msbuild
  65. +1 −1 build.cmd
  66. +68 −0 build.ps1
View
No changes.
View
@@ -0,0 +1,29 @@
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DefineConstants>TRACE;DEBUG</DefineConstants>
+ <RunCodeAnalysis>false</RunCodeAnalysis>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE;SIGN</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <RunCodeAnalysis>false</RunCodeAnalysis>
+ </PropertyGroup>
+ <!-- local sign key -->
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>..\localbuild.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+</Project>
View
@@ -10,57 +10,16 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DemoApp</RootNamespace>
<AssemblyName>DemoApp</AssemblyName>
- <SccProjectName>
- </SccProjectName>
- <SccLocalPath>
- </SccLocalPath>
- <SccAuxPath>
- </SccAuxPath>
- <SccProvider>
- </SccProvider>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <OldToolsVersion>3.5</OldToolsVersion>
- <UpgradeBackupLocation>
- </UpgradeBackupLocation>
<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>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
+ <Import Project="..\CommonProperties.targets" />
<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>
+ <NoWarn>1591</NoWarn>
</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>
+ <NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
- <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -85,29 +44,5 @@
<Name>Membase</Name>
</ProjectReference>
</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.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.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>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
+ <sectionGroup name="enyim.com">
+ <section name="log" type="Enyim.Caching.Configuration.LoggerSection, Enyim.Caching" />
+ <!-- ... -->
+ </sectionGroup>
+ </configSections>
+
+ <enyim.com>
+ <log factory="Enyim.Caching.Log4NetFactory, Enyim.Caching.Log4NetAdapter" />
+ <!-- ... -->
+ </enyim.com>
+
+ <!-- Basic log4net config. Don't forget to call log4net.Configuration.XmlConfigurator.Configurator() at the start of your app. -->
+ <log4net>
+ <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
+ <layout type="log4net.Layout.PatternLayout,log4net">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
+ </layout>
+ </appender>
+ <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
+ <layout type="log4net.Layout.PatternLayout,log4net">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
+ </layout>
+ </appender>
+ <root>
+ <level value="Info" />
+ <appender-ref ref="TraceAppender" />
+ </root>
+ </log4net>
+</configuration>
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{9D3F12E6-6BDD-4DED-8B25-D877780640B4}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Enyim.Caching.Log4NetAdapter</RootNamespace>
+ <AssemblyName>Enyim.Caching.Log4NetAdapter</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <Import Project="..\CommonProperties.targets" />
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <NoWarn>1591</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <NoWarn>1591</NoWarn>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net">
+ <HintPath>..\binaries\log4net\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Log4NetFactory.cs" />
+ <Compile Include="Log4NetWrapper.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Enyim.Caching\Enyim.Caching.csproj">
+ <Project>{D438C0B3-A168-40B8-BDDD-61F0939DFF35}</Project>
+ <Name>Enyim.Caching</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Demo.config">
+ <SubType>Designer</SubType>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <GitTagMatch>emc*</GitTagMatch>
+ </PropertyGroup>
+ <Import Project="..\VersionInfo.targets" />
+</Project>
@@ -0,0 +1,40 @@
+using System;
+
+namespace Enyim.Caching
+{
+ /// <summary>
+ /// log4net log factory
+ /// </summary>
+ public class Log4NetFactory : ILogFactory
+ {
+ ILog ILogFactory.GetLogger(string name)
+ {
+ return new Log4NetWrapper(log4net.LogManager.GetLogger(name));
+ }
+
+ ILog ILogFactory.GetLogger(Type type)
+ {
+ return new Log4NetWrapper(log4net.LogManager.GetLogger(type));
+ }
+ }
+}
+
+#region [ License information ]
+/* ************************************************************
+ *
+ * Copyright (c) 2010 Attila Kiskó, enyim.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ************************************************************/
+#endregion
Oops, something went wrong.

0 comments on commit 8673380

Please sign in to comment.