├── lib ├── log4net.1.2.9.dll └── log4net.1.2.10.dll ├── src ├── .nuget │ ├── NuGet.exe │ ├── NuGet.Config │ └── NuGet.targets ├── ServiceStack.Logging.EventLog │ ├── packages.config │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── EventLogFactory.cs │ ├── ServiceStack.Logging.EventLog.csproj │ └── EventLogger.cs ├── ServiceStack.Logging.NLog │ ├── packages.config │ ├── NLogFactory.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ServiceStack.Logging.NLog.csproj │ └── NLogLogger.cs ├── ServiceStack.Logging.Log4Net │ ├── packages.config │ ├── ServiceStack.Logging.Log4Net.csproj.user │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Log4NetFactory.cs │ ├── ServiceStack.Logging.Log4Net.csproj │ └── Log4NetLogger.cs ├── ServiceStack.Logging.Elmah │ ├── packages.config │ ├── ElmahLogFactory.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ServiceStack.Logging.Elmah.csproj │ └── ElmahInterceptingLogger.cs ├── ServiceStack.Logging.sln.DotSettings ├── ServiceStack.Logging.EntLib5 │ ├── packages.config │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SerializableConfigurationSource.cs │ ├── EntLib5Factory.cs │ ├── App.config │ ├── ServiceStack.Logging.EntLib5.csproj │ └── EntLib5Logger.cs ├── BuildFile.xml └── ServiceStack.Logging.sln ├── tests └── ServiceStack.Logging.Tests │ ├── Properties │ └── AssemblyInfo.cs │ ├── UnitTests │ ├── UnitTestBase.cs │ ├── ElmahLogFactoryTest.cs │ ├── EventLogFactoryTests.cs │ ├── Log4NetFactoryTests.cs │ ├── LogManagerTests.cs │ ├── ElmahInterceptingLoggerTests.cs │ ├── EntLib5LoggerTests.cs │ ├── Log4NetLoggerTests.cs │ ├── DebugLoggerTests.cs │ ├── EventLoggerTests.cs │ ├── EntLib5FactoryTests.cs │ └── App.config │ ├── UseCases │ ├── UseCaseBase.cs │ ├── UsingLog4Net.cs │ ├── UsingEventLog.cs │ └── UsingEntLib5.cs │ ├── ServiceStack.Logging.Tests.csproj.user │ ├── log4net.Test.config │ ├── packages.config │ ├── Support │ └── TestBase.cs │ ├── entlib5.test.config │ └── ServiceStack.Logging.Tests.csproj ├── NuGet ├── ServiceStack.Logging.NLog │ ├── lib │ │ └── net35 │ │ │ └── ServiceStack.Logging.NLog.dll │ └── servicestack.logging.nlog.nuspec ├── ServiceStack.Logging.Elmah │ ├── lib │ │ └── net35 │ │ │ └── ServiceStack.Logging.Elmah.dll │ └── servicestack.logging.elmah.nuspec ├── ServiceStack.Logging.EntLib5 │ ├── lib │ │ └── net35 │ │ │ ├── ServiceStack.Logging.EntLib5.dll │ │ │ └── ServiceStack.Logging.EntLib5.dll.config │ └── servicestack.logging.entlib5.nuspec ├── ServiceStack.Logging.Log4Net │ ├── lib │ │ └── net35 │ │ │ └── ServiceStack.Logging.Log4Net.dll │ └── servicestack.logging.log4net.nuspec ├── ServiceStack.Logging.EventLog │ ├── lib │ │ └── net35 │ │ │ └── ServiceStack.Logging.EventLog.dll │ └── servicestack.logging.eventlog.nuspec ├── ServiceStack.Logging.Log4Netv129 │ ├── lib │ │ └── net35 │ │ │ └── ServiceStack.Logging.Log4Netv129.dll │ └── servicestack.logging.log4netv129.nuspec ├── ServiceStack.Logging.Log4Netv1210 │ ├── lib │ │ └── net35 │ │ │ └── ServiceStack.Logging.Log4Netv1210.dll │ └── servicestack.logging.log4netv1210.nuspec ├── NuGetPack.cmd └── NuGetPush.cmd ├── CONTRIBUTING.md ├── .gitignore ├── license.txt └── README.md /lib/log4net.1.2.9.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/lib/log4net.1.2.9.dll -------------------------------------------------------------------------------- /src/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/src/.nuget/NuGet.exe -------------------------------------------------------------------------------- /lib/log4net.1.2.10.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/lib/log4net.1.2.10.dll -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/tests/ServiceStack.Logging.Tests/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.NLog/lib/net35/ServiceStack.Logging.NLog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/NuGet/ServiceStack.Logging.NLog/lib/net35/ServiceStack.Logging.NLog.dll -------------------------------------------------------------------------------- /src/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.Elmah/lib/net35/ServiceStack.Logging.Elmah.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/NuGet/ServiceStack.Logging.Elmah/lib/net35/ServiceStack.Logging.Elmah.dll -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.EntLib5/lib/net35/ServiceStack.Logging.EntLib5.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/NuGet/ServiceStack.Logging.EntLib5/lib/net35/ServiceStack.Logging.EntLib5.dll -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.Log4Net/lib/net35/ServiceStack.Logging.Log4Net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/NuGet/ServiceStack.Logging.Log4Net/lib/net35/ServiceStack.Logging.Log4Net.dll -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.EventLog/lib/net35/ServiceStack.Logging.EventLog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/NuGet/ServiceStack.Logging.EventLog/lib/net35/ServiceStack.Logging.EventLog.dll -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.Log4Netv129/lib/net35/ServiceStack.Logging.Log4Netv129.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/NuGet/ServiceStack.Logging.Log4Netv129/lib/net35/ServiceStack.Logging.Log4Netv129.dll -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.Log4Netv1210/lib/net35/ServiceStack.Logging.Log4Netv1210.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStackV3/ServiceStack.Logging/HEAD/NuGet/ServiceStack.Logging.Log4Netv1210/lib/net35/ServiceStack.Logging.Log4Netv1210.dll -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/UnitTestBase.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack.Logging.Tests.Support; 2 | 3 | namespace ServiceStack.Logging.Tests.UnitTests 4 | { 5 | public class UnitTestBase : TestBase 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UseCases/UseCaseBase.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack.Logging.Tests.Support; 2 | using NUnit.Framework; 3 | 4 | namespace ServiceStack.Logging.Tests.UseCases 5 | { 6 | public class UseCaseBase : TestBase 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EventLog/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.NLog/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Log4Net/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Elmah/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributor License Agreement 2 | 3 | * Please sign the [Contributor License Agreement](https://docs.google.com/forms/d/16Op0fmKaqYtxGL4sg7w_g-cXXyCoWjzppgkuqzOeKyk/viewform) in order to have your changes merged. 4 | 5 | See the [Contributing Wiki](https://github.com/ServiceStack/ServiceStack/wiki/Contributing) to learn how you can Contribute! 6 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UseCases/UsingLog4Net.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack.Logging.Log4Net; 2 | using NUnit.Framework; 3 | 4 | namespace ServiceStack.Logging.Tests.UseCases 5 | { 6 | [TestFixture] 7 | public class UsingLog4Net 8 | { 9 | [Test] 10 | public void Log4NetUseCase() 11 | { 12 | LogManager.LogFactory = new Log4NetFactory(); 13 | ILog log = LogManager.GetLogger(GetType()); 14 | 15 | log.Debug("Debug Event Log Entry."); 16 | log.Warn("Warning Event Log Entry."); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/ServiceStack.Logging.Tests.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ProjectFiles 5 | 6 | 7 | 8 | 9 | 10 | 11 | en-US 12 | false 13 | 14 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/log4net.Test.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Log4Net/ServiceStack.Logging.Log4Net.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ProjectFiles 5 | 6 | 7 | 8 | 9 | 10 | 11 | en-US 12 | false 13 | 14 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | <data><IncludeFilters /><ExcludeFilters /></data> 3 | <data /> -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UseCases/UsingEventLog.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack.Logging.EventLog; 2 | using ServiceStack.Logging.Log4Net; 3 | using NUnit.Framework; 4 | 5 | namespace ServiceStack.Logging.Tests.UseCases 6 | { 7 | [TestFixture] 8 | public class UsingEventLog 9 | { 10 | [Test] 11 | public void EventLogUseCase() 12 | { 13 | LogManager.LogFactory = new EventLogFactory("ServiceStack.Logging.Tests", "Application"); 14 | ILog log = LogManager.GetLogger(GetType()); 15 | 16 | log.Debug("Start Logging..."); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/ElmahLogFactoryTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | using ServiceStack.Logging.Elmah; 4 | using ServiceStack.Logging.Log4Net; 5 | 6 | namespace ServiceStack.Logging.Tests.UnitTests 7 | { 8 | [TestFixture] 9 | public class ElmahLogFactoryTests 10 | { 11 | [Test] 12 | public void ElmahLogFactoryTest() 13 | { 14 | ElmahLogFactory factory = new ElmahLogFactory(new Log4NetFactory()); 15 | ILog log = factory.GetLogger(GetType()); 16 | Assert.IsNotNull(log); 17 | Assert.IsNotNull(log as ElmahInterceptingLogger); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /NuGet/NuGetPack.cmd: -------------------------------------------------------------------------------- 1 | SET NUGET=..\src\.nuget\nuget 2 | %NUGET% pack ServiceStack.Logging.Elmah\servicestack.logging.elmah.nuspec -symbols 3 | %NUGET% pack ServiceStack.Logging.EntLib5\servicestack.logging.entlib5.nuspec -symbols 4 | %NUGET% pack ServiceStack.Logging.EventLog\servicestack.logging.eventlog.nuspec -symbols 5 | %NUGET% pack ServiceStack.Logging.Log4Net\servicestack.logging.log4net.nuspec -symbols 6 | %NUGET% pack ServiceStack.Logging.Log4Netv129\servicestack.logging.log4netv129.nuspec -symbols 7 | %NUGET% pack ServiceStack.Logging.Log4Netv1210\servicestack.logging.log4netv1210.nuspec -symbols 8 | %NUGET% pack ServiceStack.Logging.NLog\servicestack.logging.nlog.nuspec -symbols 9 | 10 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EntLib5/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/EventLogFactoryTests.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack.Logging.EventLog; 2 | using ServiceStack.Logging.Log4Net; 3 | using NUnit.Framework; 4 | 5 | namespace ServiceStack.Logging.Tests.UnitTests 6 | { 7 | [TestFixture] 8 | public class EventLogFactoryTests 9 | { 10 | [Test] 11 | public void EventLogFactoryTest() 12 | { 13 | EventLogFactory factory = new EventLogFactory("ServiceStack.Logging.Tests", "Application"); 14 | ILog log = factory.GetLogger(GetType()); 15 | Assert.IsNotNull(log); 16 | Assert.IsNotNull(log as EventLogger); 17 | 18 | factory = new EventLogFactory("ServiceStack.Logging.Tests"); 19 | log = factory.GetLogger(GetType()); 20 | Assert.IsNotNull(log); 21 | Assert.IsNotNull(log as EventLogger); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /NuGet/NuGetPush.cmd: -------------------------------------------------------------------------------- 1 | SET NUGET=..\src\.nuget\nuget 2 | %NUGET% push ServiceStack.Logging.Elmah.3.9.60.nupkg 3 | %NUGET% push ServiceStack.Logging.Elmah.3.9.60.symbols.nupkg 4 | %NUGET% push ServiceStack.Logging.EntLib5.3.9.60.nupkg 5 | %NUGET% push ServiceStack.Logging.EntLib5.3.9.60.symbols.nupkg 6 | %NUGET% push ServiceStack.Logging.EventLog.3.9.60.nupkg 7 | %NUGET% push ServiceStack.Logging.EventLog.3.9.60.symbols.nupkg 8 | %NUGET% push ServiceStack.Logging.Log4Net.3.9.60.nupkg 9 | %NUGET% push ServiceStack.Logging.Log4Net.3.9.60.symbols.nupkg 10 | %NUGET% push ServiceStack.Logging.Log4Netv129.3.9.60.nupkg 11 | %NUGET% push ServiceStack.Logging.Log4Netv129.3.9.60.symbols.nupkg 12 | %NUGET% push ServiceStack.Logging.Log4Netv1210.3.9.60.nupkg 13 | %NUGET% push ServiceStack.Logging.Log4Netv1210.3.9.60.symbols.nupkg 14 | %NUGET% push ServiceStack.Logging.NLog.3.9.60.nupkg 15 | %NUGET% push ServiceStack.Logging.NLog.3.9.60.symbols.nupkg 16 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.NLog/NLogFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ServiceStack.Logging; 3 | 4 | namespace ServiceStack.Logging.NLogger 5 | { 6 | /// 7 | /// ILogFactory that creates an NLog ILog logger 8 | /// 9 | public class NLogFactory : ServiceStack.Logging.ILogFactory 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | public NLogFactory() { } 15 | 16 | /// 17 | /// Gets the logger. 18 | /// 19 | /// The type. 20 | /// 21 | public ILog GetLogger(Type type) 22 | { 23 | return new NLogLogger(type); 24 | } 25 | 26 | /// 27 | /// Gets the logger. 28 | /// 29 | /// Name of the type. 30 | /// 31 | public ILog GetLogger(string typeName) 32 | { 33 | return new NLogLogger(typeName); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/Support/TestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using NUnit.Framework; 4 | using Rhino.Mocks; 5 | 6 | namespace ServiceStack.Logging.Tests.Support 7 | { 8 | public class TestBase 9 | { 10 | private MockRepository mocks; 11 | 12 | protected virtual MockRepository Mocks 13 | { 14 | get { return mocks; } 15 | } 16 | 17 | [SetUp] 18 | protected virtual void SetUp() 19 | { 20 | mocks = new MockRepository(); 21 | } 22 | 23 | [TearDown] 24 | protected virtual void TearDown() 25 | { 26 | mocks = null; 27 | } 28 | 29 | protected virtual void ReplayAll() 30 | { 31 | Mocks.ReplayAll(); 32 | } 33 | 34 | protected virtual void VerifyAll() 35 | { 36 | try 37 | { 38 | Mocks.VerifyAll(); 39 | } 40 | catch (InvalidOperationException ex) 41 | { 42 | Debug.Print("InvalidOperationException thrown: {0}", ex.Message); 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/Log4NetFactoryTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NUnit.Framework; 3 | using ServiceStack.Logging.Log4Net; 4 | 5 | namespace ServiceStack.Logging.Tests.UnitTests 6 | { 7 | [TestFixture] 8 | public class Log4NetFactoryTests 9 | { 10 | [Test] 11 | public void Log4NetFactoryTest() 12 | { 13 | Log4NetFactory factory = new Log4NetFactory(); 14 | ILog log = factory.GetLogger(GetType()); 15 | Assert.IsNotNull(log); 16 | Assert.IsNotNull(log as Log4NetLogger); 17 | 18 | factory = new Log4NetFactory(true); 19 | log = factory.GetLogger(GetType().Name); 20 | Assert.IsNotNull(log); 21 | Assert.IsNotNull(log as Log4NetLogger); 22 | } 23 | 24 | [Test] 25 | public void Log4NetFactoryTestWithExistingConfigFile() 26 | { 27 | const string configFile = "log4net.Test.config"; 28 | Assert.IsTrue(File.Exists(configFile), "Test setup failure. Required log4net config file is missing."); 29 | 30 | Log4NetFactory factory = new Log4NetFactory(configFile); 31 | 32 | ILog log = factory.GetLogger(GetType()); 33 | Assert.IsNotNull(log); 34 | Assert.IsNotNull(log as Log4NetLogger); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/LogManagerTests.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack.Logging.Support.Logging; 2 | using NUnit.Framework; 3 | using Rhino.Mocks; 4 | 5 | namespace ServiceStack.Logging.Tests.UnitTests 6 | { 7 | [TestFixture] 8 | public class LogManagerTests : UnitTestBase 9 | { 10 | [Test] 11 | public void LogManager_DefaultTest() 12 | { 13 | ILog log = LogManager.GetLogger(GetType()); 14 | Assert.IsNotNull(log); 15 | Assert.IsNotNull(LogManager.LogFactory as DebugLogFactory); 16 | Assert.IsNotNull(log as DebugLogger); 17 | 18 | log = LogManager.GetLogger(GetType().Name); 19 | Assert.IsNotNull(log); 20 | Assert.IsNotNull(LogManager.LogFactory as DebugLogFactory); 21 | Assert.IsNotNull(log as DebugLogger); 22 | } 23 | 24 | [Test] 25 | public void LogManager_InjectionTest() 26 | { 27 | ILogFactory factory = Mocks.CreateMock(); 28 | Expect.Call(factory.GetLogger(GetType())).Return(Mocks.DynamicMock()); 29 | ReplayAll(); 30 | 31 | LogManager.LogFactory = factory; 32 | ILog log = LogManager.GetLogger(GetType()); 33 | 34 | Assert.IsNotNull(log); 35 | VerifyAll(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.EventLog/servicestack.logging.eventlog.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ServiceStack.Logging.EventLog 5 | 3.9.60 6 | ServiceStack.Logging.EventLog 7 | Demis Bellot 8 | Demis Bellot 9 | Windows Event Log integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework 10 | false 11 | 12 | Provides EventLog logging integration for other ServiceStack projects 13 | 14 | https://github.com/ServiceStack/ServiceStack.Logging 15 | https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE 16 | http://www.servicestack.net/logo-100x100.png 17 | servicestack log logging eventlog 18 | en-US 19 | servicestack.net 2013 and contributors 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.Elmah/servicestack.logging.elmah.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ServiceStack.Logging.Elmah 5 | 3.9.60 6 | ServiceStack.Logging.Elmah 7 | Demis Bellot 8 | Demis Bellot 9 | Elmah logging integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework 10 | false 11 | 12 | Provides Elmah logging integration for other ServiceStack projects 13 | 14 | https://github.com/ServiceStack/ServiceStack.Logging 15 | https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE 16 | http://www.servicestack.net/logo-100x100.png 17 | servicestack log logging elmah 18 | en-US 19 | servicestack.net 2013 and contributors 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.NLog/servicestack.logging.nlog.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ServiceStack.Logging.NLog 5 | 3.9.60 6 | ServiceStack.Logging.NLog 7 | Demis Bellot 8 | Demis Bellot 9 | NLog logging integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework 10 | false 11 | 12 | Provides NLog logging integration for other ServiceStack projects 13 | 14 | https://github.com/ServiceStack/ServiceStack.Logging 15 | https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE 16 | http://www.servicestack.net/logo-100x100.png 17 | servicestack log logging nlog 18 | en-US 19 | servicestack.net 2013 and contributors 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.Log4Net/servicestack.logging.log4net.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ServiceStack.Logging.Log4Net 5 | 3.9.60 6 | ServiceStack.Logging.Log4Net 7 | Demis Bellot 8 | Demis Bellot 9 | log4Net logging integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework 10 | false 11 | 12 | Provides log4net logging integration for other ServiceStack projects 13 | 14 | https://github.com/ServiceStack/ServiceStack.Logging 15 | https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE 16 | http://www.servicestack.net/logo-100x100.png 17 | servicestack log logging log4net 18 | en-US 19 | servicestack.net 2013 and contributors 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UseCases/UsingEntLib5.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack.Logging.EntLib5; 2 | using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; 3 | using NUnit.Framework; 4 | 5 | namespace ServiceStack.Logging.Tests.UseCases 6 | { 7 | [TestFixture] 8 | public class UsingEntLib5 9 | { 10 | [Test] 11 | public void EntLib5UseCase() 12 | { 13 | // construct the Configuration Source to use 14 | var builder = new ConfigurationSourceBuilder(); 15 | 16 | // fluent API configuration 17 | builder.ConfigureLogging() 18 | .WithOptions 19 | .DoNotRevertImpersonation() 20 | .LogToCategoryNamed("Simple") 21 | .SendTo.FlatFile("Simple Log File") 22 | .FormatWith(new FormatterBuilder() 23 | .TextFormatterNamed("simpleFormat") 24 | .UsingTemplate("{timestamp} : {message}{newline}")) 25 | .ToFile("simple.log"); 26 | 27 | var configSource = new DictionaryConfigurationSource(); 28 | builder.UpdateConfigurationWithReplace(configSource); 29 | EnterpriseLibraryContainer.Current 30 | = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); 31 | 32 | ILog log = LogManager.GetLogger(GetType()); 33 | 34 | log.Debug("Debug Event Log Entry."); 35 | log.Warn("Warning Event Log Entry."); 36 | 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.Log4Netv1210/servicestack.logging.log4netv1210.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ServiceStack.Logging.Log4Netv1210 5 | 3.9.60 6 | ServiceStack.Logging.Log4Netv1210 7 | Demis Bellot 8 | Demis Bellot 9 | log4Net 1.2.10 logging integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework 10 | false 11 | 12 | Provides log4net logging integration for other ServiceStack projects 13 | 14 | https://github.com/ServiceStack/ServiceStack.Logging 15 | https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE 16 | http://www.servicestack.net/logo-100x100.png 17 | servicestack log logging log4net 18 | en-US 19 | servicestack.net 2013 and contributors 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.Log4Netv129/servicestack.logging.log4netv129.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ServiceStack.Logging.Log4Netv129 5 | 3.9.60 6 | ServiceStack.Logging.Log4Netv129 7 | Demis Bellot 8 | Demis Bellot 9 | log4Net 1.2.9 logging integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework 10 | false 11 | 12 | Provides log4net 1.2.9 logging integration for other ServiceStack projects 13 | 14 | https://github.com/ServiceStack/ServiceStack.Logging 15 | https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE 16 | http://www.servicestack.net/logo-100x100.png 17 | servicestack log logging log4net 18 | en-US 19 | servicestack.net 2013 and contributors 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/ElmahInterceptingLoggerTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | using Rhino.Mocks; 4 | using ServiceStack.Logging.Elmah; 5 | 6 | namespace ServiceStack.Logging.Tests.UnitTests 7 | { 8 | [TestFixture] 9 | public class ElmahInterceptingLoggerTests 10 | { 11 | [Test] 12 | public void ElmahInterceptingLoggerTest() 13 | { 14 | var wrappedLogger = MockRepository.GenerateStub(); 15 | ILog log = new ElmahInterceptingLogger(wrappedLogger); 16 | Assert.IsNotNull(log); 17 | } 18 | 19 | [Test] 20 | public void ElmahInterceptingLogger_LoggingTest() 21 | { 22 | string message = "Error Message"; 23 | Exception ex = new Exception(); 24 | string messageFormat = "Message Format: message: {0}, exception: {1}"; 25 | 26 | var wrappedLogger = MockRepository.GenerateStub(); 27 | ILog log = new ElmahInterceptingLogger(wrappedLogger); 28 | Assert.IsNotNull(log); 29 | 30 | log.Debug(message); 31 | log.Debug(message, ex); 32 | log.DebugFormat(messageFormat, message, ex.Message); 33 | 34 | log.Error(message); 35 | log.Error(message, ex); 36 | log.ErrorFormat(messageFormat, message, ex.Message); 37 | 38 | log.Fatal(message); 39 | log.Fatal(message, ex); 40 | log.FatalFormat(messageFormat, message, ex.Message); 41 | 42 | log.Info(message); 43 | log.Info(message, ex); 44 | log.InfoFormat(messageFormat, message, ex.Message); 45 | 46 | log.Warn(message); 47 | log.Warn(message, ex); 48 | log.WarnFormat(messageFormat, message, ex.Message); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.EntLib5/servicestack.logging.entlib5.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ServiceStack.Logging.EntLib5 5 | 3.9.60 6 | ServiceStack.Logging.EntLib5 7 | Demis Bellot 8 | Demis Bellot 9 | Enterprise Library 5.0 Logging Application Block integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework 10 | false 11 | 12 | Provides Enterprise Library 5.0 Logging Application Block logging integration for other ServiceStack projects 13 | 14 | https://github.com/ServiceStack/ServiceStack.Logging 15 | https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE 16 | http://www.servicestack.net/logo-100x100.png 17 | servicestack log logging nlog 18 | en-US 19 | servicestack.net 2013 and contributors 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/EntLib5LoggerTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ServiceStack.Logging.EntLib5; 3 | using NUnit.Framework; 4 | 5 | namespace ServiceStack.Logging.Tests.UnitTests 6 | { 7 | [TestFixture] 8 | public class EntLib5LoggerTests 9 | { 10 | [Test] 11 | public void EntLib5LoggerTest() 12 | { 13 | ILog log = new EntLib5Logger(); 14 | Assert.IsNotNull(log); 15 | } 16 | 17 | [Test] 18 | public void EntLib5Logger_LoggingTest() 19 | { 20 | const string message = "Error Message"; 21 | Exception ex = new Exception(); 22 | //string messageFormat = "Message Format: message: {0}, exception: {1}"; 23 | 24 | ILog log = new EntLib5Logger(); 25 | Assert.IsNotNull(log); 26 | 27 | log.Debug(message); 28 | log.Debug(message, ex); 29 | //log.DebugFormat(messageFormat, message, ex.Message); 30 | 31 | log.Error(message); 32 | log.Error(message, ex); 33 | //log.ErrorFormat(messageFormat, message, ex.Message); 34 | 35 | log.Fatal(message); 36 | log.Fatal(message, ex); 37 | //log.FatalFormat(messageFormat, message, ex.Message); 38 | 39 | log.Info(message); 40 | log.Info(message, ex); 41 | //log.InfoFormat(messageFormat, message, ex.Message); 42 | 43 | log.Warn(message); 44 | log.Warn(message, ex); 45 | //log.WarnFormat(messageFormat, message, ex.Message); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | .idea/ 4 | latest/ 5 | /env-vars.bat 6 | *.suo 7 | #ignore thumbnails created by windows 8 | [Tt]humbs.db 9 | #Ignore files build by Visual Studio 10 | *.[Oo]bj 11 | *.exe 12 | *.pdb 13 | *.user 14 | *.aps 15 | *.pch 16 | *.vspscc 17 | *.scc 18 | *.*scc 19 | *_i.c 20 | *_p.c 21 | *.ncb 22 | *.suo 23 | *.tlb 24 | *.tlh 25 | *.bak 26 | *.[Cc]ache 27 | *.ilk 28 | *.log 29 | [Bb]in 30 | [Dd]ebug*/ 31 | *.lib 32 | *.sbr 33 | *.resharper.user 34 | obj/ 35 | [Rr]elease*/ 36 | _[Rr]e[Ss]harper*/ 37 | *.resharper 38 | [Tt]est[Rr]esult* 39 | App_Data/ 40 | *.tli 41 | *.sdf 42 | *.opensdf 43 | *.unsuccessfulbuild 44 | *.opt 45 | *.plg 46 | ipch/ 47 | Ankh.Load 48 | Ankh.NoLoad 49 | *.vshost.* 50 | *.FileListAbsolute.txt 51 | *.clw 52 | *.eto 53 | *.vsmdi 54 | *.dbmdl 55 | *.dbproj.schemaview 56 | *DXCore.Solution 57 | *.sln.docstates 58 | *.fbpInf 59 | lint.db 60 | 61 | #OS junk files 62 | *.DS_Store 63 | [Ii]ndex.dat 64 | [Ss]torage.dat 65 | 66 | #ASP.NET 67 | [Pp]recompiled[Ww]eb/ 68 | UpgradeLog*.* 69 | _[Uu]pgradeReport_[Ff]iles 70 | *.[Pp]ublish.xml 71 | 72 | #Silverlight 73 | [Cc]lientBin/ 74 | *.xap 75 | 76 | #WCF 77 | *.svclog 78 | 79 | #SSRS and SSMS 80 | *.rdl.data 81 | *.sqlsuo 82 | 83 | #TFS Files 84 | *.nlb 85 | 86 | #Other Source Control 87 | *.orig 88 | CVS/ 89 | .svn 90 | 91 | # Office Temp Files 92 | ~$* 93 | 94 | #NuGet 95 | packages/ 96 | *.nupkg 97 | 98 | #Miscellaneous Files 99 | *.exe 100 | *.fb6lck 101 | *.fbl6 102 | *.patch 103 | *.sig 104 | *.tmp 105 | Backup* -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Elmah/ElmahLogFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ServiceStack.Logging.Elmah 4 | { 5 | /// 6 | /// Elmah log factory that wraps another log factory, providing interception facilities on log calls. For Error or Fatal calls, the 7 | /// details will be logged to Elmah in addition to the originally intended logger. For all other log types, only the original logger is 8 | /// used. 9 | /// 10 | /// 9/2/2011. 11 | public class ElmahLogFactory : ILogFactory 12 | { 13 | private readonly ILogFactory _logFactory; 14 | 15 | /// Constructor. 16 | /// 9/2/2011. 17 | /// The log factory that provides the original . 18 | public ElmahLogFactory(ILogFactory logFactory) 19 | { 20 | if (null == logFactory) { throw new ArgumentNullException("logFactory"); } 21 | 22 | _logFactory = logFactory; 23 | } 24 | 25 | /// Gets a logger from the wrapped logFactory. 26 | /// 9/2/2011. 27 | /// Name of the type. 28 | /// The logger. 29 | public ILog GetLogger(string typeName) 30 | { 31 | return new ElmahInterceptingLogger(_logFactory.GetLogger(typeName)); 32 | } 33 | 34 | /// Gets a logger from the wrapped logFactory. 35 | /// 9/2/2011. 36 | /// The type. 37 | /// The logger. 38 | public ILog GetLogger(Type type) 39 | { 40 | return new ElmahInterceptingLogger(_logFactory.GetLogger(type)); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/Log4NetLoggerTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ServiceStack.Logging.Log4Net; 3 | using NUnit.Framework; 4 | 5 | namespace ServiceStack.Logging.Tests.UnitTests 6 | { 7 | [TestFixture] 8 | public class Log4NetLoggerTests 9 | { 10 | [Test] 11 | public void Log4NetLoggerTest() 12 | { 13 | ILog log = new Log4NetLogger(GetType()); 14 | Assert.IsNotNull(log); 15 | 16 | log = new Log4NetLogger(GetType().Name); 17 | Assert.IsNotNull(log); 18 | } 19 | 20 | [Test] 21 | public void Log4NetLogger_LoggingTest() 22 | { 23 | string message = "Error Message"; 24 | Exception ex = new Exception(); 25 | string messageFormat = "Message Format: message: {0}, exception: {1}"; 26 | 27 | ILog log = new Log4NetLogger(GetType()); 28 | Assert.IsNotNull(log); 29 | 30 | log.Debug(message); 31 | log.Debug(message, ex); 32 | log.DebugFormat(messageFormat, message, ex.Message); 33 | 34 | log.Error(message); 35 | log.Error(message, ex); 36 | log.ErrorFormat(messageFormat, message, ex.Message); 37 | 38 | log.Fatal(message); 39 | log.Fatal(message, ex); 40 | log.FatalFormat(messageFormat, message, ex.Message); 41 | 42 | log.Info(message); 43 | log.Info(message, ex); 44 | log.InfoFormat(messageFormat, message, ex.Message); 45 | 46 | log.Warn(message); 47 | log.Warn(message, ex); 48 | log.WarnFormat(messageFormat, message, ex.Message); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/DebugLoggerTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ServiceStack.Logging.Support.Logging; 3 | using NUnit.Framework; 4 | 5 | namespace ServiceStack.Logging.Tests.UnitTests 6 | { 7 | [TestFixture] 8 | public class DebugLoggerTests 9 | { 10 | [Test] 11 | public void Log4NetLoggerTest() 12 | { 13 | ILog log = new DebugLogger(GetType()); 14 | Assert.IsNotNull(log); 15 | 16 | log = new DebugLogger(GetType().Name); 17 | Assert.IsNotNull(log); 18 | } 19 | 20 | [Test] 21 | public void DebugLogger_LoggingTest() 22 | { 23 | string message = "Error Message"; 24 | Exception ex = new Exception(); 25 | string messageFormat = "Message Format: message: {0}, exception: {1}"; 26 | 27 | ILog log = new DebugLogger(GetType()); 28 | Assert.IsNotNull(log); 29 | 30 | log.Debug(message); 31 | log.Debug(message, ex); 32 | log.DebugFormat(messageFormat, messageFormat, ex.Message); 33 | 34 | log.Error(message); 35 | log.Error(message, ex); 36 | log.ErrorFormat(messageFormat, messageFormat, ex.Message); 37 | 38 | log.Fatal(message); 39 | log.Fatal(message, ex); 40 | log.FatalFormat(messageFormat, messageFormat, ex.Message); 41 | 42 | log.Info(message); 43 | log.Info(message, ex); 44 | log.InfoFormat(messageFormat, messageFormat, ex.Message); 45 | 46 | log.Warn(message); 47 | log.Warn(message, ex); 48 | log.WarnFormat(messageFormat, messageFormat, ex.Message); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Log4Net/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ServiceStack.Logging.Log4Net")] 9 | [assembly: AssemblyDescription(@"Provides log4net logging integration for other ServiceStack projects 10 | Includes: 11 | - ServiceStack.Logging.Log4Net.dll 12 | Dependencies: 13 | - ServiceStack.Interfaces.dll")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("Demis Bellot")] 16 | [assembly: AssemblyProduct("ServiceStack.Logging.Log4Net")] 17 | [assembly: AssemblyCopyright("Copyright � ServiceStack 2013")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | [assembly: Guid("d575bdba-a6db-464c-8c41-bd0694b79b02")] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // 32 | // Major Version 33 | // Minor Version 34 | // Build Number 35 | // Revision 36 | // 37 | // You can specify all the values or you can default the Revision and Build Numbers 38 | // by using the '*' as shown below: 39 | [assembly: AssemblyVersion("1.0.10")] 40 | [assembly: AssemblyFileVersion("1.0.10")] 41 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EventLog/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ServiceStack.Logging.EventLog")] 9 | [assembly: AssemblyDescription(@"Provides EventLog logging integration for other ServiceStack projects 10 | Includes: 11 | - ServiceStack.Logging.EventLog.dll 12 | Dependencies: 13 | - ServiceStack.Interfaces.dll")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("Demis Bellot")] 16 | [assembly: AssemblyProduct("ServiceStack.Logging.EventLog")] 17 | [assembly: AssemblyCopyright("Copyright � ServiceStack 2013")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | [assembly: Guid("350720fd-3394-4b99-b09e-bc8336c502ad")] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // 32 | // Major Version 33 | // Minor Version 34 | // Build Number 35 | // Revision 36 | // 37 | // You can specify all the values or you can default the Revision and Build Numbers 38 | // by using the '*' as shown below: 39 | [assembly: AssemblyVersion("1.0.10")] 40 | [assembly: AssemblyFileVersion("1.0.10")] 41 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Elmah/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ServiceStack.Logging.Elmah")] 9 | [assembly: AssemblyDescription(@"Provides Elmah logging integration for other ServiceStack projects 10 | Includes: 11 | - ServiceStack.Logging.Elmah.dll 12 | Dependencies: 13 | - ServiceStack.Interfaces.dll")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("Demis Bellot")] 16 | [assembly: AssemblyProduct("ServiceStack.Logging.Elmah")] 17 | [assembly: AssemblyCopyright("Copyright © ServiceStack 2013")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | [assembly: ComVisible(false)] 25 | 26 | // The following GUID is for the ID of the typelib if this project is exposed to COM 27 | [assembly: Guid("ae1c5e8f-160c-45fc-ba1c-da65f6e01d25")] 28 | 29 | // Version information for an assembly consists of the following four values: 30 | // 31 | // Major Version 32 | // Minor Version 33 | // Build Number 34 | // Revision 35 | // 36 | // You can specify all the values or you can default the Build and Revision Numbers 37 | // by using the '*' as shown below: 38 | // [assembly: AssemblyVersion("1.0.*")] 39 | [assembly: AssemblyVersion("1.0.10")] 40 | [assembly: AssemblyFileVersion("1.0.10")] 41 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.NLog/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ServiceStack.Logging.NLog")] 9 | [assembly: AssemblyDescription(@"Provides NLog logging integration for other ServiceStack projects 10 | Includes: 11 | - ServiceStack.Logging.NLog.dll 12 | Dependencies: 13 | - ServiceStack.Interfaces.dll")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("Demis Bellot")] 16 | [assembly: AssemblyProduct("ServiceStack.Logging.NLog")] 17 | [assembly: AssemblyCopyright("Copyright © ServiceStack 2013")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | [assembly: Guid("9c2fa048-ddf0-4626-aa54-173eec579d69")] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // 32 | // Major Version 33 | // Minor Version 34 | // Build Number 35 | // Revision 36 | // 37 | // You can specify all the values or you can default the Build and Revision Numbers 38 | // by using the '*' as shown below: 39 | // [assembly: AssemblyVersion("1.0.*")] 40 | [assembly: AssemblyVersion("1.0.10")] 41 | [assembly: AssemblyFileVersion("1.0.10")] 42 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EntLib5/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ServiceStack.Logging.EntLib5")] 9 | [assembly: AssemblyDescription(@"Provides Enterprise Library 5.0 Logging Application Block logging integration for other ServiceStack projects 10 | Includes: 11 | - ServiceStack.Logging.EntLib5.dll 12 | Dependencies: 13 | - ServiceStack.Interfaces.dll")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("Kevin Howard")] 16 | [assembly: AssemblyProduct("ServiceStack.Logging.EntLib5")] 17 | [assembly: AssemblyCopyright("Copyright © ServiceStack 2013")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | [assembly: ComVisible(false)] 25 | 26 | // The following GUID is for the ID of the typelib if this project is exposed to COM 27 | [assembly: Guid("a4ed4cac-c55c-4f8c-83ca-b4a2ede918d3")] 28 | 29 | // Version information for an assembly consists of the following four values: 30 | // 31 | // Major Version 32 | // Minor Version 33 | // Build Number 34 | // Revision 35 | // 36 | // You can specify all the values or you can default the Build and Revision Numbers 37 | // by using the '*' as shown below: 38 | // [assembly: AssemblyVersion("1.0.*")] 39 | [assembly: AssemblyVersion("3.9.60.0")] 40 | [assembly: AssemblyFileVersion("3.9.60.0")] 41 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EventLog/EventLogFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ServiceStack.Logging.EventLog 4 | { 5 | /// 6 | /// ILogFactory used to create an EventLogger 7 | /// 8 | public class EventLogFactory : ILogFactory 9 | { 10 | private readonly string eventLogName; 11 | private readonly string eventLogSource; 12 | 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// Name of the event log. 17 | public EventLogFactory(string eventLogName) : this(eventLogName, null) { } 18 | 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | /// Name of the event log. Default is 'ServiceStack.Logging.EventLog' 23 | /// The event log source. Default is 'Application' 24 | public EventLogFactory(string eventLogName, string eventLogSource) 25 | { 26 | this.eventLogName = eventLogName ?? "ServiceStack.Logging.EventLog"; 27 | this.eventLogSource = eventLogSource ?? "Application"; 28 | } 29 | 30 | /// 31 | /// Gets the logger. 32 | /// 33 | /// The type. 34 | /// 35 | public ILog GetLogger(Type type) 36 | { 37 | return GetLogger(type.ToString()); 38 | } 39 | 40 | /// 41 | /// Gets the logger. 42 | /// 43 | /// Name of the type. 44 | /// 45 | public ILog GetLogger(string typeName) 46 | { 47 | return new EventLogger(eventLogName, eventLogSource); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/EventLoggerTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ServiceStack.Logging.EventLog; 3 | using ServiceStack.Logging.Log4Net; 4 | using NUnit.Framework; 5 | 6 | namespace ServiceStack.Logging.Tests.UnitTests 7 | { 8 | [TestFixture] 9 | public class EventLoggerTests 10 | { 11 | [Test] 12 | public void EventLoggerTest() 13 | { 14 | ILog log = new EventLogger("ServiceStack.Logging.Tests", "Application"); 15 | Assert.IsNotNull(log); 16 | } 17 | 18 | [Test] 19 | [ExpectedException(typeof(ArgumentNullException))] 20 | public void EventLogger_NullLogNameTest() 21 | { 22 | ILog log = new EventLogger(null, "Application"); 23 | } 24 | 25 | [Test] 26 | [ExpectedException(typeof(ArgumentNullException))] 27 | public void EventLogger_NullSourceNameTest() 28 | { 29 | ILog log = new EventLogger("ServiceStack.Logging.Tests", null); 30 | } 31 | 32 | [Test] 33 | public void EventLogger_LoggingTest() 34 | { 35 | string message = "Error Message"; 36 | Exception ex = new Exception("Exception"); 37 | string messageFormat = "Message Format: message: {0}, exception: {1}"; 38 | 39 | ILog log = new EventLogger("ServiceStack.Logging.Tests", "Application"); 40 | Assert.IsNotNull(log); 41 | 42 | log.Debug(message); 43 | log.Debug(message, ex); 44 | log.DebugFormat(messageFormat, message, ex.Message); 45 | 46 | log.Error(message); 47 | log.Error(message, ex); 48 | log.ErrorFormat(messageFormat, message, ex.Message); 49 | 50 | log.Fatal(message); 51 | log.Fatal(message, ex); 52 | log.FatalFormat(messageFormat, message, ex.Message); 53 | 54 | log.Info(message); 55 | log.Info(message, ex); 56 | log.InfoFormat(messageFormat, message, ex.Message); 57 | 58 | log.Warn(message); 59 | log.Warn(message, ex); 60 | log.WarnFormat(messageFormat, message, ex.Message); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/BuildFile.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | bin\$(Configuration) 8 | Null 9 | Null 10 | $(ProjectDir)\$(ProjectFileRoot).Tests 11 | 12 | $(ProjectDir)\$(ProjectFileRoot).sln 13 | $(ProjectTestDir)\$(ProjectFileRoot).Tests.csproj 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EntLib5/SerializableConfigurationSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.IO; 5 | using System.Reflection; 6 | using System.Xml; 7 | using System.Xml.Linq; 8 | using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; 9 | 10 | namespace ServiceStack.Logging.EntLib5 11 | { 12 | public class SerializableConfigurationSource : IConfigurationSource 13 | { 14 | readonly Dictionary sections = new Dictionary(); 15 | 16 | public ConfigurationSection GetSection(string sectionName) 17 | { 18 | ConfigurationSection configSection; 19 | 20 | if (sections.TryGetValue(sectionName, out configSection)) 21 | { 22 | SerializableConfigurationSection section = configSection as SerializableConfigurationSection; 23 | 24 | if (section != null) 25 | { 26 | using (StringWriter xml = new StringWriter()) 27 | using (XmlWriter xmlwriter = XmlWriter.Create(xml)) 28 | { 29 | section.WriteXml(xmlwriter); 30 | xmlwriter.Flush(); 31 | 32 | MethodInfo methodInfo = section.GetType().GetMethod("DeserializeSection", BindingFlags.NonPublic | BindingFlags.Instance); 33 | methodInfo.Invoke(section, new object[] { XDocument.Parse(xml.ToString()).CreateReader() }); 34 | 35 | return configSection; 36 | } 37 | } 38 | } 39 | 40 | return null; 41 | } 42 | 43 | public void Add(string sectionName, ConfigurationSection configurationSection) 44 | { 45 | sections[sectionName] = configurationSection; 46 | } 47 | 48 | public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) 49 | { 50 | throw new NotImplementedException(); 51 | } 52 | 53 | public void Remove(string sectionName) 54 | { 55 | sections.Remove(sectionName); 56 | } 57 | 58 | public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) 59 | { 60 | throw new NotImplementedException(); 61 | } 62 | 63 | public event EventHandler SourceChanged; 64 | 65 | public void Dispose() { } 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Log4Net/Log4NetFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace ServiceStack.Logging.Log4Net 5 | { 6 | /// 7 | /// ILogFactory that creates an Log4Net ILog logger 8 | /// 9 | public class Log4NetFactory : ILogFactory 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | public Log4NetFactory() : this(false) { } 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// if set to true [will use the xml definition in App.Config to configure log4 net]. 20 | public Log4NetFactory(bool configureLog4Net) 21 | { 22 | if (configureLog4Net) 23 | { 24 | log4net.Config.XmlConfigurator.Configure(); 25 | } 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The log4 net configuration file to load and watch. If not found configures from App.Config. 32 | public Log4NetFactory(string log4NetConfigurationFile) 33 | { 34 | //Restart logging if necessary 35 | log4net.Repository.ILoggerRepository rootRepository = log4net.LogManager.GetRepository(); 36 | if (rootRepository != null) 37 | rootRepository.Shutdown(); 38 | 39 | if (File.Exists(log4NetConfigurationFile)) 40 | log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(log4NetConfigurationFile)); 41 | else 42 | log4net.Config.XmlConfigurator.Configure(); 43 | } 44 | 45 | /// 46 | /// Gets the logger. 47 | /// 48 | /// The type. 49 | /// 50 | public ILog GetLogger(Type type) 51 | { 52 | return new Log4NetLogger(type); 53 | } 54 | 55 | /// 56 | /// Gets the logger. 57 | /// 58 | /// Name of the type. 59 | /// 60 | public ILog GetLogger(string typeName) 61 | { 62 | return new Log4NetLogger(typeName); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 6 | $(NuGetToolsPath)\nuget.exe 7 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) 8 | $([System.IO.Path]::Combine($(SolutionDir), "packages")) 9 | $(TargetDir.Trim('\\')) 10 | 11 | 12 | "" 13 | 14 | 15 | false 16 | 17 | 18 | false 19 | 20 | 21 | "$(NuGetExePath)" install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)" 22 | "$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols 23 | 24 | 25 | 26 | RestorePackages; 27 | $(BuildDependsOn); 28 | 29 | 30 | 31 | 32 | $(BuildDependsOn); 33 | BuildPackage; 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 46 | 47 | 48 | 49 | 51 | 52 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/EntLib5FactoryTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NUnit.Framework; 3 | using ServiceStack.Logging.EntLib5; 4 | using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; 5 | 6 | namespace ServiceStack.Logging.Tests.UnitTests 7 | { 8 | [TestFixture] 9 | public class EntLib5FactoryTests 10 | { 11 | [Test] 12 | public void EntLib5FactoryTest() 13 | { 14 | // initialize the EntLib5 Logger Factory - will use App.Config for settings 15 | EntLib5Factory factory = new EntLib5Factory(); 16 | ILog log = factory.GetLogger(GetType()); 17 | Assert.IsNotNull(log); 18 | Assert.IsNotNull(log as EntLib5Logger); 19 | } 20 | 21 | [Test] 22 | public void EntLib5FactoryTestWithExistingConfigFile() 23 | { 24 | // set up a Configuration file and ensure it exists 25 | const string configFile = "EntLib5.Test.config"; 26 | Assert.IsTrue(File.Exists(configFile), "Test setup failure. Required Enterprise Library config file is missing."); 27 | 28 | // initialize the EntLib5 Logger factory with configuration file 29 | EntLib5Factory factory = new EntLib5Factory(configFile); 30 | 31 | ILog log = factory.GetLogger(GetType()); 32 | Assert.IsNotNull(log); 33 | Assert.IsNotNull(log as EntLib5Logger); 34 | } 35 | 36 | [Test] 37 | public void EntLib5FactoryTestWithFluentConfig() 38 | { 39 | // construct the Configuration Source to use 40 | var builder = new ConfigurationSourceBuilder(); 41 | 42 | // fluent API configuration 43 | builder.ConfigureLogging() 44 | .WithOptions 45 | .DoNotRevertImpersonation() 46 | .LogToCategoryNamed("Simple") 47 | .SendTo.FlatFile("Simple Log File") 48 | .FormatWith(new FormatterBuilder() 49 | .TextFormatterNamed("simpleFormat") 50 | .UsingTemplate("{timestamp} : {message}{newline}")) 51 | .ToFile("simple.log"); 52 | 53 | var configSource = new DictionaryConfigurationSource(); 54 | builder.UpdateConfigurationWithReplace(configSource); 55 | EnterpriseLibraryContainer.Current 56 | = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); 57 | 58 | // initialize the EntLib5 Logger factory with configuration file 59 | EntLib5Factory factory = new EntLib5Factory(); 60 | 61 | ILog log = factory.GetLogger(GetType()); 62 | Assert.IsNotNull(log); 63 | Assert.IsNotNull(log as EntLib5Logger); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EntLib5/EntLib5Factory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using Microsoft.Practices.EnterpriseLibrary.Logging; 4 | using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration; 5 | using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; 6 | using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Fluent; 7 | 8 | namespace ServiceStack.Logging.EntLib5 9 | { 10 | public class EntLib5Factory : LogWriterFactory, ILogFactory 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public EntLib5Factory() { } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The enterprise library 5.0 configuration file to load and watch. Supercedes any configuration found in the Config file. 21 | public EntLib5Factory(string EntLib5ConfigurationFile) 22 | { 23 | // verify provided file exists 24 | var fi = new System.IO.FileInfo(EntLib5ConfigurationFile); 25 | if (fi.Exists) 26 | { 27 | var builder = new ConfigurationSourceBuilder(); 28 | var EntLib5ConfigurationSrc = new FileConfigurationSource(EntLib5ConfigurationFile, true); 29 | 30 | builder.UpdateConfigurationWithReplace(EntLib5ConfigurationSrc); 31 | EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(EntLib5ConfigurationSrc); 32 | } 33 | } 34 | 35 | /// 36 | /// Initializes a new instance of the class. 37 | /// 38 | /// The enterprise library 5.0 configuration source to load. Supercedes any configuration found in the Config file. 39 | public EntLib5Factory(IConfigurationSource EntLib5ConfigurationSrc) 40 | { 41 | // replace any settings from App.Config with the ones in the provided config source 42 | var builder = new ConfigurationSourceBuilder(); 43 | builder.UpdateConfigurationWithReplace(EntLib5ConfigurationSrc); 44 | EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(EntLib5ConfigurationSrc); 45 | } 46 | 47 | 48 | /// 49 | /// Gets the logger. 50 | /// 51 | /// The type. 52 | /// 53 | public ILog GetLogger(Type type) 54 | { 55 | return new EntLib5Logger(type); 56 | } 57 | 58 | /// 59 | /// Gets the logger. 60 | /// 61 | /// Name of the type. 62 | /// 63 | public ILog GetLogger(string typeName) 64 | { 65 | return new EntLib5Logger(typeName); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Elmah/ServiceStack.Logging.Elmah.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {EE43BF1E-CF97-4215-A5A3-46D1C363F928} 9 | Library 10 | Properties 11 | ServiceStack.Logging.Elmah 12 | ServiceStack.Logging.Elmah 13 | v4.0 14 | 512 15 | 16 | ..\..\src\ 17 | true 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | AllRules.ruleset 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | False 40 | ..\packages\elmah.corelibrary.1.2.2\lib\Elmah.dll 41 | 42 | 43 | False 44 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Common.dll 45 | 46 | 47 | False 48 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Interfaces.dll 49 | 50 | 51 | False 52 | ..\packages\ServiceStack.Text.3.9.59\lib\net35\ServiceStack.Text.dll 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 74 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | ServiceStack 2 | Copyright (c) 2013 Service Stack 3 | =============================================================================== 4 | 5 | This program is free software: you can redistribute it and/or modify it 6 | under the terms of the GNU Affero General Public License as published by the 7 | Free Software Foundation, either version 3 of the License, see 8 | http://www.gnu.org/licenses/agpl-3.0.html. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 13 | 14 | 15 | FOSS License Exception 16 | =============================================================================== 17 | 18 | This Exception applies to open source applications built with ServiceStack and 19 | ServiceStack extensions ("The Software"), and to open source Derivative Works of 20 | the Software, that use the Software under the terms of GNU Affero General 21 | Public License, version 3 ("AGPLv3"). The Exception extends AGPLv3 by providing 22 | additional grants that allows developers of FOSS applications to include ServiceStack 23 | with their FOSS applications in combination with other software licensed under 24 | the licenses from the "Open Source License List" below, provided that: 25 | 26 | You obey the AGPLv3 terms for the Software and the Derivative Work, except for 27 | the separate parts of the Derivative Work ("Additions") which constitute independent 28 | work and are not dervied from the Software. 29 | 30 | - All Additions are distributed subject to one of the licenses listed below. 31 | - Your software distribution provides complete source code for the Additions. 32 | - The Derivative Work and its Additions are intended for use in end-user applications 33 | and do not constitute software intended for use by software developers, such as 34 | software libraries, components, and development kits. 35 | - If you violate any of the terms in this Exception, you lose all rights granted 36 | to you by the Exception and revert to the terms of AGPLv3. 37 | 38 | Service Stack reserves all rights not expressly granted in these terms and conditions. 39 | 40 | Open Source License List 41 | 42 | Name Version 43 | Academic Free License 2.0 44 | Apache Software License 2.0 45 | Apple Public Source License 2.0 46 | Artistic license From Perl 5.8.0 47 | BSD license July 22 1999 48 | Common Development and Distribution License (CDDL) 1.0 49 | Common Public License 1.0 50 | Eclipse Public License 1.0 51 | Educational Community License 2.0 52 | European Union Public License (EUPL) 1.1 53 | GNU General Public License (GPL) 2.0 54 | GNU Library or "Lesser" General Public License (LGPL) 3.0 55 | Jabber Open Source License 1.0 56 | MIT License (As listed in file MIT-License.txt) - 57 | Mozilla Public License (MPL) 1.0/1.1 58 | Open Software License 2.0 59 | OpenSSL license (with original SSLeay license) 2003 (1998) 60 | University of Illinois/NCSA Open Source License - 61 | W3C License 2001 62 | X11 License 2001 63 | Zlib/libpng License - 64 | 65 | 66 | 67 | Commercial License 68 | =========================================================================== 69 | In addition to this license, ServiceStack is offered under a commerical license. 70 | Contact team@servicestack.net for details. 71 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.NLog/ServiceStack.Logging.NLog.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {6B31F200-073C-46D4-B389-05646E035939} 9 | Library 10 | Properties 11 | ServiceStack.Logging.NLog 12 | ServiceStack.Logging.NLog 13 | v4.0 14 | 512 15 | ..\..\src\ 16 | true 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | False 39 | ..\packages\NLog.2.0.1.2\lib\net35\NLog.dll 40 | 41 | 42 | False 43 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Common.dll 44 | 45 | 46 | False 47 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Interfaces.dll 48 | 49 | 50 | False 51 | ..\packages\ServiceStack.Text.3.9.59\lib\net35\ServiceStack.Text.dll 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 77 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EntLib5/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |
6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Elmah/ElmahInterceptingLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | using Elmah; 4 | 5 | namespace ServiceStack.Logging.Elmah 6 | { 7 | /// Writes Elmah intercepting logger. 8 | /// 9/2/2011. 9 | public class ElmahInterceptingLogger 10 | : ILog 11 | { 12 | private readonly ILog log; 13 | 14 | /// Constructor. 15 | /// 16 | /// Logs to the given Elmah ErrorLog. Only Error and Fatal are passed along to Elmah, while all other errors will be written to the 17 | /// wrapped logger. 18 | /// 19 | /// Thrown when either the wrapped ILog or Elmah ErrorLog are null. 20 | /// The underlying log to write to. 21 | /// The error log. 22 | public ElmahInterceptingLogger(ILog log) 23 | { 24 | if (null == log) { throw new ArgumentNullException("log"); } 25 | 26 | this.log = log; 27 | } 28 | 29 | public void Debug(object message, Exception exception) 30 | { 31 | log.Debug(message, exception); 32 | } 33 | 34 | public void Debug(object message) 35 | { 36 | log.Debug(message); 37 | } 38 | 39 | public void DebugFormat(string format, params object[] args) 40 | { 41 | log.DebugFormat(format, args); 42 | } 43 | 44 | public void Error(object message, Exception exception) 45 | { 46 | try { 47 | ErrorLog.GetDefault(HttpContext.Current).Log(new Error(exception, HttpContext.Current)); 48 | } 49 | catch { 50 | ErrorLog.GetDefault(null).Log(new Error(exception)); 51 | } 52 | log.Error(message, exception); 53 | } 54 | 55 | public void Error(object message) 56 | { 57 | try { 58 | ErrorLog.GetDefault(HttpContext.Current).Log(new Error(new System.ApplicationException(message.ToString()), HttpContext.Current)); 59 | } 60 | catch { 61 | ErrorLog.GetDefault(null).Log(new Error(new System.ApplicationException(message.ToString()))); 62 | } 63 | log.Error(message); 64 | } 65 | 66 | public void ErrorFormat(string format, params object[] args) 67 | { 68 | try { 69 | ErrorLog.GetDefault(HttpContext.Current).Log(new Error(new System.ApplicationException(string.Format(format, args)), HttpContext.Current)); 70 | } 71 | catch { 72 | ErrorLog.GetDefault(null).Log(new Error(new System.ApplicationException(string.Format(format, args)))); 73 | } 74 | log.ErrorFormat(format, args); 75 | } 76 | 77 | public void Fatal(object message, Exception exception) 78 | { 79 | try { 80 | ErrorLog.GetDefault(HttpContext.Current).Log(new Error(exception, HttpContext.Current)); 81 | } 82 | catch { 83 | ErrorLog.GetDefault(null).Log(new Error(exception)); 84 | } 85 | log.Fatal(message, exception); 86 | } 87 | 88 | public void Fatal(object message) 89 | { 90 | try { 91 | ErrorLog.GetDefault(HttpContext.Current).Log(new Error(new System.ApplicationException(message.ToString()), HttpContext.Current)); 92 | } 93 | catch { 94 | ErrorLog.GetDefault(null).Log(new Error(new System.ApplicationException(message.ToString()))); 95 | } 96 | log.Fatal(message); 97 | } 98 | 99 | public void FatalFormat(string format, params object[] args) 100 | { 101 | try { 102 | ErrorLog.GetDefault(HttpContext.Current).Log(new Error(new System.ApplicationException(string.Format(format, args)), HttpContext.Current)); 103 | } 104 | catch { 105 | ErrorLog.GetDefault(null).Log(new Error(new System.ApplicationException(string.Format(format, args)))); 106 | } 107 | log.FatalFormat(format, args); 108 | } 109 | 110 | public void Info(object message, Exception exception) 111 | { 112 | log.Info(message, exception); 113 | } 114 | 115 | public void Info(object message) 116 | { 117 | log.Info(message); 118 | } 119 | 120 | public void InfoFormat(string format, params object[] args) 121 | { 122 | log.InfoFormat(format, args); 123 | } 124 | 125 | public bool IsDebugEnabled 126 | { 127 | get { return log.IsDebugEnabled; } 128 | } 129 | 130 | public void Warn(object message, Exception exception) 131 | { 132 | log.Warn(message, exception); 133 | } 134 | 135 | public void Warn(object message) 136 | { 137 | log.Warn(message); 138 | } 139 | 140 | public void WarnFormat(string format, params object[] args) 141 | { 142 | log.WarnFormat(format, args); 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The latest Logging projects have now been merged into the main [ServiceStack](https://github.com/ServiceStack/ServiceStack/) repo. 2 | 3 | ---- 4 | 5 | [Join the ServiceStack Google+ group](http://groups.google.com/group/servicestack) or 6 | follow [@ServiceStack](http://twitter.com/servicestack) for project updates. 7 | 8 | ## An implementation-free logging API for .Net 9 | 10 | **ServiceStack.Logging** is an implementation and dependency-free logging API with adapters for all of .NET's popular logging providers. 11 | It allows your business logic to bind to an easily-mockable and testable dependency-free interface whilst providing the flexibility to switch logging providers at runtime. 12 | 13 | ## Download on NuGet 14 | 15 | Currently there are 6 different .NET logging providers available on NuGet: 16 | 17 | #### Install-Package [ServiceStack.Logging.NLog](https://nuget.org/packages/ServiceStack.Logging.NLog) 18 | #### Install-Package [ServiceStack.Logging.Elmah](https://nuget.org/packages/ServiceStack.Logging.Elmah) 19 | #### Install-Package [ServiceStack.Logging.Log4Net](https://nuget.org/packages/ServiceStack.Logging.Log4Net) 20 | #### Install-Package [ServiceStack.Logging.Log4Netv129](https://nuget.org/packages/ServiceStack.Logging.Log4Netv129) 21 | #### Install-Package [ServiceStack.Logging.EventLog](https://nuget.org/packages/ServiceStack.Logging.EventLog) 22 | #### Install-Package [ServiceStack.Logging.EnterpriseLibrary5](https://nuget.org/packages/ServiceStack.Logging.EnterpriseLibrary5/) 23 | 24 | Note: The ConsoleLogger and DebugLogger and are already built-in and bind to .NET Framework's Console and Debug loggers 25 | 26 | _Commercial support will be available for ServiceStack, contact team@servicestack.net for details_ 27 | 28 | ----- 29 | 30 | Even in the spirit of **Bind to interfaces, not implemenations**, many .NET projects still have 31 | a hard dependency to [log4net](http://logging.apache.org/log4net/index.html). 32 | 33 | Although log4net is the standard for logging in .NET, potential problems can arise from your libraries having a hard dependency on it: 34 | 35 | * Your library needs to be shipped with a third-party dependency 36 | * Potential conflicts can occur when different libraries have dependency on different versions of log4net (e.g. the 1.2.9 / 1.2.10 dependency problem). 37 | * You may want to use a different logging provider (i.e. network distributed logging) 38 | * You want your logging for Unit and Integration tests to redirect to the Console or Debug logger without any configuraiton. 39 | * Something better like [elmah](http://code.google.com/p/elmah/) can come along requiring a major rewrite to take advantage of it 40 | 41 | ServiceStack.Logging solves these problems by providing an implementation-free ILog interface that your application logic can bind to 42 | where your Application Host project can bind to the concrete logging implementation at deploy or runtime. 43 | 44 | ServiceStack.Logging also includes adapters for the following logging providers: 45 | 46 | * Elmah 47 | * NLog 48 | * Log4Net 1.2.10+ 49 | * Log4Net 1.2.9 50 | * Enterprise Library 5.0 51 | * EventLog 52 | * Console Log 53 | * Debug Log 54 | * Null / Empty Log 55 | 56 | # Usage Examples 57 | 58 | Once on your App Startup, either In your AppHost.cs or Global.asax file inject the concrete logging implementation that your app should use, e.g. 59 | 60 | ## Log4Net 61 | LogManager.LogFactory = new Log4NetFactory(true); //Also runs log4net.Config.XmlConfigurator.Configure() 62 | 63 | ## Event Log 64 | LogManager.LogFactory = new EventLogFactory("ServiceStack.Logging.Tests", "Application"); 65 | 66 | Then your application logic can bind to and use a lightweight implementation-free ILog which at runtime will be an instance of the concrete implementation configured in your host: 67 | 68 | ILog log = LogManager.GetLogger(GetType()); 69 | 70 | log.Debug("Debug Event Log Entry."); 71 | log.Warn("Warning Event Log Entry."); 72 | 73 | ## Copying 74 | 75 | Since September 2013, ServiceStack source code is available under GNU Affero General Public License/FOSS License Exception, see license.txt in the source. Alternative commercial licensing is also available, contact team@servicestack.net for details. 76 | 77 | ## Contributing 78 | 79 | Commits should be made to the **v3-fixes** branch so they can be merged into both **v3** and **master** (v4) release branches. 80 | Contributors need to approve the [Contributor License Agreement](https://docs.google.com/forms/d/16Op0fmKaqYtxGL4sg7w_g-cXXyCoWjzppgkuqzOeKyk/viewform) before any code will be reviewed, see the [Contributing wiki](https://github.com/ServiceStack/ServiceStack/wiki/Contributing) for more details. 81 | -------------------------------------------------------------------------------- /NuGet/ServiceStack.Logging.EntLib5/lib/net35/ServiceStack.Logging.EntLib5.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
7 |
10 | 11 | 12 | 13 | 17 | 18 | 22 | 26 | 27 | 28 | 29 | 39 | 40 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/entlib5.test.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
7 |
10 | 11 | 12 | 13 | 17 | 18 | 22 | 26 | 27 | 28 | 29 | 39 | 40 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/UnitTests/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
7 |
10 | 11 | 12 | 13 | 17 | 18 | 22 | 26 | 27 | 28 | 29 | 39 | 40 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Logging.EventLog", "ServiceStack.Logging.EventLog\ServiceStack.Logging.EventLog.csproj", "{D920BA88-E394-4C75-94E3-78D7298A8457}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Logging.Log4Net", "ServiceStack.Logging.Log4Net\ServiceStack.Logging.Log4Net.csproj", "{C44A6E80-326E-4036-8906-62E881F4727D}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Logging.Tests", "..\tests\ServiceStack.Logging.Tests\ServiceStack.Logging.Tests.csproj", "{DDDA27EC-5855-4E89-9971-C117EC08BDE3}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Logging.NLog", "ServiceStack.Logging.NLog\ServiceStack.Logging.NLog.csproj", "{6B31F200-073C-46D4-B389-05646E035939}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Logging.Elmah", "ServiceStack.Logging.Elmah\ServiceStack.Logging.Elmah.csproj", "{EE43BF1E-CF97-4215-A5A3-46D1C363F928}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{CA7CF53F-9C02-4A5B-B9AF-390B1F7B095C}" 15 | ProjectSection(SolutionItems) = preProject 16 | ..\build\build.bat = ..\build\build.bat 17 | ..\build\build.proj = ..\build\build.proj 18 | ..\build\build.tasks = ..\build\build.tasks 19 | ..\NuGet\ServiceStack.Logging.Elmah\servicestack.logging.elmah.nuspec = ..\NuGet\ServiceStack.Logging.Elmah\servicestack.logging.elmah.nuspec 20 | ..\NuGet\ServiceStack.Logging.EntLib5\servicestack.logging.entlib5.nuspec = ..\NuGet\ServiceStack.Logging.EntLib5\servicestack.logging.entlib5.nuspec 21 | ..\NuGet\ServiceStack.Logging.EventLog\servicestack.logging.eventlog.nuspec = ..\NuGet\ServiceStack.Logging.EventLog\servicestack.logging.eventlog.nuspec 22 | ..\NuGet\ServiceStack.Logging.Log4Net\servicestack.logging.log4net.nuspec = ..\NuGet\ServiceStack.Logging.Log4Net\servicestack.logging.log4net.nuspec 23 | ..\NuGet\ServiceStack.Logging.Log4Netv1210\servicestack.logging.log4netv1210.nuspec = ..\NuGet\ServiceStack.Logging.Log4Netv1210\servicestack.logging.log4netv1210.nuspec 24 | ..\NuGet\ServiceStack.Logging.Log4Netv129\servicestack.logging.log4netv129.nuspec = ..\NuGet\ServiceStack.Logging.Log4Netv129\servicestack.logging.log4netv129.nuspec 25 | ..\NuGet\ServiceStack.Logging.NLog\servicestack.logging.nlog.nuspec = ..\NuGet\ServiceStack.Logging.NLog\servicestack.logging.nlog.nuspec 26 | EndProjectSection 27 | EndProject 28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Logging.EntLib5", "ServiceStack.Logging.EntLib5\ServiceStack.Logging.EntLib5.csproj", "{EDD72ADC-327C-4152-B84B-B48552311534}" 29 | EndProject 30 | Global 31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 32 | Debug|Any CPU = Debug|Any CPU 33 | Release|Any CPU = Release|Any CPU 34 | EndGlobalSection 35 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 36 | {D920BA88-E394-4C75-94E3-78D7298A8457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {D920BA88-E394-4C75-94E3-78D7298A8457}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {D920BA88-E394-4C75-94E3-78D7298A8457}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {D920BA88-E394-4C75-94E3-78D7298A8457}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {C44A6E80-326E-4036-8906-62E881F4727D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {C44A6E80-326E-4036-8906-62E881F4727D}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {C44A6E80-326E-4036-8906-62E881F4727D}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {C44A6E80-326E-4036-8906-62E881F4727D}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {DDDA27EC-5855-4E89-9971-C117EC08BDE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {DDDA27EC-5855-4E89-9971-C117EC08BDE3}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {DDDA27EC-5855-4E89-9971-C117EC08BDE3}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {DDDA27EC-5855-4E89-9971-C117EC08BDE3}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {6B31F200-073C-46D4-B389-05646E035939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {6B31F200-073C-46D4-B389-05646E035939}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {6B31F200-073C-46D4-B389-05646E035939}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {6B31F200-073C-46D4-B389-05646E035939}.Release|Any CPU.Build.0 = Release|Any CPU 52 | {EE43BF1E-CF97-4215-A5A3-46D1C363F928}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {EE43BF1E-CF97-4215-A5A3-46D1C363F928}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {EE43BF1E-CF97-4215-A5A3-46D1C363F928}.Release|Any CPU.ActiveCfg = Release|Any CPU 55 | {EE43BF1E-CF97-4215-A5A3-46D1C363F928}.Release|Any CPU.Build.0 = Release|Any CPU 56 | {EDD72ADC-327C-4152-B84B-B48552311534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 57 | {EDD72ADC-327C-4152-B84B-B48552311534}.Debug|Any CPU.Build.0 = Debug|Any CPU 58 | {EDD72ADC-327C-4152-B84B-B48552311534}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {EDD72ADC-327C-4152-B84B-B48552311534}.Release|Any CPU.Build.0 = Release|Any CPU 60 | EndGlobalSection 61 | GlobalSection(SolutionProperties) = preSolution 62 | HideSolutionNode = FALSE 63 | EndGlobalSection 64 | GlobalSection(ExtensibilityGlobals) = postSolution 65 | EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.2\lib\NET35;packages\Unity.Interception.2.1.505.2\lib\NET35;packages\EnterpriseLibrary.Common.5.0.505.0\lib\NET35;packages\EnterpriseLibrary.Logging.5.0.505.1\lib\NET35 66 | EndGlobalSection 67 | GlobalSection(MonoDevelopProperties) = preSolution 68 | StartupItem = ServiceStack.Logging.EventLog\ServiceStack.Logging.EventLog.csproj 69 | EndGlobalSection 70 | EndGlobal 71 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EntLib5/ServiceStack.Logging.EntLib5.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {EDD72ADC-327C-4152-B84B-B48552311534} 9 | Library 10 | Properties 11 | ServiceStack.Logging.EntLib5 12 | ServiceStack.Logging.EntLib5 13 | v4.0 14 | 512 15 | ..\ 16 | true 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | False 39 | ..\packages\EnterpriseLibrary.Common.5.0.505.0\lib\NET35\Microsoft.Practices.EnterpriseLibrary.Common.dll 40 | 41 | 42 | False 43 | ..\packages\EnterpriseLibrary.Logging.5.0.505.1\lib\NET35\Microsoft.Practices.EnterpriseLibrary.Logging.dll 44 | 45 | 46 | ..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll 47 | 48 | 49 | ..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll 50 | 51 | 52 | ..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll 53 | 54 | 55 | ..\packages\Unity.Interception.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Interception.dll 56 | 57 | 58 | ..\packages\Unity.Interception.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Interception.Configuration.dll 59 | 60 | 61 | False 62 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Common.dll 63 | 64 | 65 | False 66 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Interfaces.dll 67 | 68 | 69 | False 70 | ..\packages\ServiceStack.Text.3.9.59\lib\net35\ServiceStack.Text.dll 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 99 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EventLog/ServiceStack.Logging.EventLog.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {D920BA88-E394-4C75-94E3-78D7298A8457} 9 | Library 10 | Properties 11 | ServiceStack.Logging.EventLog 12 | ServiceStack.Logging.EventLog 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 3.5 24 | 25 | 26 | false 27 | v4.0 28 | publish\ 29 | true 30 | Disk 31 | false 32 | Foreground 33 | 7 34 | Days 35 | false 36 | false 37 | true 38 | 0 39 | 1.0.0.%2a 40 | false 41 | true 42 | ..\..\src\ 43 | true 44 | 45 | 46 | 47 | true 48 | full 49 | false 50 | bin\Debug\ 51 | DEBUG;TRACE 52 | prompt 53 | 4 54 | AllRules.ruleset 55 | 56 | 57 | pdbonly 58 | true 59 | bin\Release\ 60 | TRACE 61 | prompt 62 | 4 63 | AllRules.ruleset 64 | 65 | 66 | 67 | False 68 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Common.dll 69 | 70 | 71 | False 72 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Interfaces.dll 73 | 74 | 75 | False 76 | ..\packages\ServiceStack.Text.3.9.59\lib\net35\ServiceStack.Text.dll 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | False 90 | .NET Framework 3.5 SP1 Client Profile 91 | false 92 | 93 | 94 | False 95 | .NET Framework 2.0 %28x86%29 96 | true 97 | 98 | 99 | False 100 | .NET Framework 3.0 %28x86%29 101 | false 102 | 103 | 104 | False 105 | .NET Framework 3.5 106 | false 107 | 108 | 109 | False 110 | .NET Framework 3.5 SP1 111 | false 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 126 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Log4Net/ServiceStack.Logging.Log4Net.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {C44A6E80-326E-4036-8906-62E881F4727D} 9 | Library 10 | Properties 11 | ServiceStack.Logging.Log4Net 12 | ServiceStack.Logging.Log4Net 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 3.5 24 | 25 | 26 | false 27 | v4.0 28 | publish\ 29 | true 30 | Disk 31 | false 32 | Foreground 33 | 7 34 | Days 35 | false 36 | false 37 | true 38 | 0 39 | 1.0.0.%2a 40 | false 41 | true 42 | ..\..\src\ 43 | true 44 | 45 | 46 | 47 | true 48 | full 49 | false 50 | bin\Debug\ 51 | DEBUG;TRACE 52 | prompt 53 | 4 54 | AllRules.ruleset 55 | 56 | 57 | pdbonly 58 | true 59 | bin\Release\ 60 | TRACE 61 | prompt 62 | 4 63 | AllRules.ruleset 64 | 65 | 66 | 67 | ..\packages\log4net.2.0.0\lib\net35-full\log4net.dll 68 | 69 | 70 | False 71 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Common.dll 72 | 73 | 74 | False 75 | ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Interfaces.dll 76 | 77 | 78 | False 79 | ..\packages\ServiceStack.Text.3.9.59\lib\net35\ServiceStack.Text.dll 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | False 93 | .NET Framework 3.5 SP1 Client Profile 94 | false 95 | 96 | 97 | False 98 | .NET Framework 2.0 %28x86%29 99 | true 100 | 101 | 102 | False 103 | .NET Framework 3.0 %28x86%29 104 | false 105 | 106 | 107 | False 108 | .NET Framework 3.5 109 | false 110 | 111 | 112 | False 113 | .NET Framework 3.5 SP1 114 | false 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 129 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.Log4Net/Log4NetLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ServiceStack.Logging.Log4Net 4 | { 5 | /// 6 | /// Wrapper over the log4net.1.2.10 and above logger 7 | /// 8 | public class Log4NetLogger : ILog 9 | { 10 | private readonly log4net.ILog _log; 11 | 12 | public Log4NetLogger(string typeName) 13 | { 14 | _log = log4net.LogManager.GetLogger(typeName); 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The type. 21 | public Log4NetLogger(Type type) 22 | { 23 | _log = log4net.LogManager.GetLogger(type); 24 | } 25 | 26 | public bool IsDebugEnabled { get { return _log.IsDebugEnabled; } } 27 | 28 | /// 29 | /// Logs a Debug message. 30 | /// 31 | /// The message. 32 | public void Debug(object message) 33 | { 34 | if (_log.IsDebugEnabled) 35 | _log.Debug(message); 36 | } 37 | 38 | /// 39 | /// Logs a Debug message and exception. 40 | /// 41 | /// The message. 42 | /// The exception. 43 | public void Debug(object message, Exception exception) 44 | { 45 | if (_log.IsDebugEnabled) 46 | _log.Debug(message, exception); 47 | } 48 | 49 | /// 50 | /// Logs a Debug format message. 51 | /// 52 | /// The format. 53 | /// The args. 54 | public void DebugFormat(string format, params object[] args) 55 | { 56 | if (_log.IsDebugEnabled) 57 | _log.DebugFormat(format, args); 58 | } 59 | 60 | /// 61 | /// Logs a Error message. 62 | /// 63 | /// The message. 64 | public void Error(object message) 65 | { 66 | if (_log.IsErrorEnabled) 67 | _log.Error(message); 68 | } 69 | 70 | /// 71 | /// Logs a Error message and exception. 72 | /// 73 | /// The message. 74 | /// The exception. 75 | public void Error(object message, Exception exception) 76 | { 77 | if (_log.IsErrorEnabled) 78 | _log.Error(message, exception); 79 | } 80 | 81 | /// 82 | /// Logs a Error format message. 83 | /// 84 | /// The format. 85 | /// The args. 86 | public void ErrorFormat(string format, params object[] args) 87 | { 88 | if (_log.IsErrorEnabled) 89 | _log.ErrorFormat(format, args); 90 | } 91 | 92 | /// 93 | /// Logs a Fatal message. 94 | /// 95 | /// The message. 96 | public void Fatal(object message) 97 | { 98 | if (_log.IsFatalEnabled) 99 | _log.Fatal(message); 100 | } 101 | 102 | /// 103 | /// Logs a Fatal message and exception. 104 | /// 105 | /// The message. 106 | /// The exception. 107 | public void Fatal(object message, Exception exception) 108 | { 109 | if (_log.IsFatalEnabled) 110 | _log.Fatal(message, exception); 111 | } 112 | 113 | /// 114 | /// Logs a Error format message. 115 | /// 116 | /// The format. 117 | /// The args. 118 | public void FatalFormat(string format, params object[] args) 119 | { 120 | if (_log.IsFatalEnabled) 121 | _log.FatalFormat(format, args); 122 | } 123 | 124 | /// 125 | /// Logs an Info message and exception. 126 | /// 127 | /// The message. 128 | public void Info(object message) 129 | { 130 | if (_log.IsInfoEnabled) 131 | _log.Info(message); 132 | } 133 | 134 | /// 135 | /// Logs an Info message and exception. 136 | /// 137 | /// The message. 138 | /// The exception. 139 | public void Info(object message, Exception exception) 140 | { 141 | if (_log.IsInfoEnabled) 142 | _log.Info(message, exception); 143 | } 144 | 145 | /// 146 | /// Logs an Info format message. 147 | /// 148 | /// The format. 149 | /// The args. 150 | public void InfoFormat(string format, params object[] args) 151 | { 152 | if (_log.IsInfoEnabled) 153 | _log.InfoFormat(format, args); 154 | } 155 | 156 | /// 157 | /// Logs a Warning message. 158 | /// 159 | /// The message. 160 | public void Warn(object message) 161 | { 162 | if (_log.IsWarnEnabled) 163 | _log.Warn(message); 164 | } 165 | 166 | /// 167 | /// Logs a Warning message and exception. 168 | /// 169 | /// The message. 170 | /// The exception. 171 | public void Warn(object message, Exception exception) 172 | { 173 | if (_log.IsWarnEnabled) 174 | _log.Warn(message, exception); 175 | } 176 | 177 | /// 178 | /// Logs a Warning format message. 179 | /// 180 | /// The format. 181 | /// The args. 182 | public void WarnFormat(string format, params object[] args) 183 | { 184 | if (_log.IsWarnEnabled) 185 | _log.WarnFormat(format, args); 186 | } 187 | } 188 | } -------------------------------------------------------------------------------- /src/ServiceStack.Logging.NLog/NLogLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLog; 3 | using ServiceStack.Logging; 4 | 5 | namespace ServiceStack.Logging.NLogger 6 | { 7 | /// 8 | /// Wrapper over the NLog 2.0 beta and above logger 9 | /// 10 | public class NLogLogger : ServiceStack.Logging.ILog 11 | { 12 | private readonly NLog.Logger log; 13 | 14 | public NLogLogger(string typeName) 15 | { 16 | log = NLog.LogManager.GetLogger(typeName); 17 | } 18 | 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | /// The type. 23 | public NLogLogger(Type type) 24 | { 25 | log = NLog.LogManager.GetLogger(UseFullTypeNames ? type.FullName : type.Name); 26 | } 27 | 28 | public static bool UseFullTypeNames { get; set; } 29 | 30 | public bool IsDebugEnabled { get { return log.IsDebugEnabled; } } 31 | 32 | public bool IsInfoEnabled { get { return log.IsInfoEnabled; } } 33 | 34 | public bool IsWarnEnabled { get { return log.IsWarnEnabled; } } 35 | 36 | public bool IsErrorEnabled { get { return log.IsErrorEnabled; } } 37 | 38 | public bool IsFatalEnabled { get { return log.IsFatalEnabled; } } 39 | 40 | /// 41 | /// Logs a Debug message. 42 | /// 43 | /// The message. 44 | public void Debug(object message) 45 | { 46 | if (IsDebugEnabled) 47 | Write(LogLevel.Debug, message.ToString()); 48 | } 49 | 50 | /// 51 | /// Logs a Debug message and exception. 52 | /// 53 | /// The message. 54 | /// The exception. 55 | public void Debug(object message, Exception exception) 56 | { 57 | if(IsDebugEnabled) 58 | Write(LogLevel.Debug,exception,message.ToString()); 59 | } 60 | 61 | /// 62 | /// Logs a Debug format message. 63 | /// 64 | /// The format. 65 | /// The args. 66 | public void DebugFormat(string format, params object[] args) 67 | { 68 | if (IsDebugEnabled) 69 | Write(LogLevel.Debug, format, args); 70 | } 71 | 72 | /// 73 | /// Logs a Error message. 74 | /// 75 | /// The message. 76 | public void Error(object message) 77 | { 78 | if (IsErrorEnabled) 79 | Write(LogLevel.Error,message.ToString()); 80 | } 81 | 82 | /// 83 | /// Logs a Error message and exception. 84 | /// 85 | /// The message. 86 | /// The exception. 87 | public void Error(object message, Exception exception) 88 | { 89 | if (IsErrorEnabled) 90 | Write(LogLevel.Error, exception, message.ToString()); 91 | } 92 | 93 | /// 94 | /// Logs a Error format message. 95 | /// 96 | /// The format. 97 | /// The args. 98 | public void ErrorFormat(string format, params object[] args) 99 | { 100 | if (IsErrorEnabled) 101 | Write(LogLevel.Error,format,args); 102 | } 103 | 104 | /// 105 | /// Logs a Fatal message. 106 | /// 107 | /// The message. 108 | public void Fatal(object message) 109 | { 110 | if (IsFatalEnabled) 111 | Write(LogLevel.Fatal,message.ToString()); 112 | } 113 | 114 | /// 115 | /// Logs a Fatal message and exception. 116 | /// 117 | /// The message. 118 | /// The exception. 119 | public void Fatal(object message, Exception exception) 120 | { 121 | if (IsFatalEnabled) 122 | Write(LogLevel.Fatal, exception, message.ToString()); 123 | } 124 | 125 | /// 126 | /// Logs a Error format message. 127 | /// 128 | /// The format. 129 | /// The args. 130 | public void FatalFormat(string format, params object[] args) 131 | { 132 | if (IsFatalEnabled) 133 | Write(LogLevel.Fatal, format, args); 134 | } 135 | 136 | /// 137 | /// Logs an Info message and exception. 138 | /// 139 | /// The message. 140 | public void Info(object message) 141 | { 142 | if (IsInfoEnabled) 143 | Write(LogLevel.Info,message.ToString()); 144 | } 145 | 146 | /// 147 | /// Logs an Info message and exception. 148 | /// 149 | /// The message. 150 | /// The exception. 151 | public void Info(object message, Exception exception) 152 | { 153 | if (IsInfoEnabled) 154 | Write(LogLevel.Info,exception,message.ToString()); 155 | } 156 | 157 | /// 158 | /// Logs an Info format message. 159 | /// 160 | /// The format. 161 | /// The args. 162 | public void InfoFormat(string format, params object[] args) 163 | { 164 | if (IsInfoEnabled) 165 | Write(LogLevel.Info, format, args); 166 | } 167 | 168 | /// 169 | /// Logs a Warning message. 170 | /// 171 | /// The message. 172 | public void Warn(object message) 173 | { 174 | if (IsWarnEnabled) 175 | Write(LogLevel.Warn,message.ToString()); 176 | } 177 | 178 | /// 179 | /// Logs a Warning message and exception. 180 | /// 181 | /// The message. 182 | /// The exception. 183 | public void Warn(object message, Exception exception) 184 | { 185 | if (IsWarnEnabled) 186 | Write(LogLevel.Warn,exception,message.ToString()); 187 | } 188 | 189 | /// 190 | /// Logs a Warning format message. 191 | /// 192 | /// The format. 193 | /// The args. 194 | public void WarnFormat(string format, params object[] args) 195 | { 196 | if (IsWarnEnabled) 197 | Write(LogLevel.Warn, format, args); 198 | } 199 | 200 | private void Write(LogLevel level, string format, params object[] args) 201 | { 202 | //preserve call site info - see here: http://stackoverflow.com/questions/3947136/problem-matching-specific-nlog-logger-name 203 | var logEventInfo = new LogEventInfo(level, log.Name, null, format, args); 204 | log.Log(typeof(NLogLogger), logEventInfo); 205 | } 206 | 207 | private void Write(LogLevel level, Exception exception, string format, params object[] args) 208 | { 209 | var exceptionEventInfo = new LogEventInfo(level, log.Name, null, format, args, exception); 210 | log.Log(typeof(NLogLogger), exceptionEventInfo); 211 | } 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EventLog/EventLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Text; 4 | 5 | namespace ServiceStack.Logging.EventLog 6 | { 7 | /// 8 | /// ILog used to write to the Event Log 9 | /// 10 | public class EventLogger : ILog 11 | { 12 | private const string NEW_LINE = "\r\n\r\n"; 13 | private const string ERROR_MSG = "An error occurred in the application: {0}\r\nException: {1}"; 14 | 15 | private readonly string eventLogSource; 16 | private readonly string eventLogName; 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// Name of the event log. 22 | /// The event log source. 23 | public EventLogger(string eventLogName, string eventLogSource) 24 | { 25 | if (string.IsNullOrEmpty(eventLogName)) 26 | { 27 | throw new ArgumentNullException("eventLogName"); 28 | } 29 | if (string.IsNullOrEmpty(eventLogSource)) 30 | { 31 | throw new ArgumentNullException("eventLogSource"); 32 | } 33 | this.eventLogName = eventLogName; 34 | this.eventLogSource = eventLogSource; 35 | } 36 | 37 | public bool IsDebugEnabled { get { return true; } } 38 | 39 | /// 40 | /// Writes the specified message. 41 | /// 42 | /// The message. 43 | /// Type of the event log. 44 | private void Write(object message, EventLogEntryType eventLogType) 45 | { 46 | Write(message, null, eventLogType); 47 | } 48 | 49 | /// 50 | /// Writes the specified message. 51 | /// 52 | /// The message. 53 | /// The execption. 54 | /// Type of the event log. 55 | private void Write(object message, Exception execption, EventLogEntryType eventLogType) 56 | { 57 | StringBuilder sb = new StringBuilder(); 58 | 59 | System.Diagnostics.EventLog eventLogger = new System.Diagnostics.EventLog(); 60 | if (!System.Diagnostics.EventLog.SourceExists(eventLogSource)) 61 | { 62 | System.Diagnostics.EventLog.CreateEventSource(eventLogSource, eventLogName); 63 | } 64 | 65 | sb.Append(message).Append(NEW_LINE); 66 | while (execption != null) 67 | { 68 | sb.Append("Message: ").Append(execption.Message).Append(NEW_LINE) 69 | .Append("Source: ").Append(execption.Source).Append(NEW_LINE) 70 | .Append("Target site: ").Append(execption.TargetSite).Append(NEW_LINE) 71 | .Append("Stack trace: ").Append(execption.StackTrace).Append(NEW_LINE); 72 | 73 | // Walk the InnerException tree 74 | execption = execption.InnerException; 75 | } 76 | 77 | eventLogger.Source = eventLogSource; 78 | eventLogger.WriteEntry(String.Format(ERROR_MSG, eventLogName, sb), eventLogType); 79 | } 80 | 81 | /// 82 | /// Logs a Debug message. 83 | /// 84 | /// The message. 85 | public void Debug(object message) 86 | { 87 | Write("DEBUG: " + message, EventLogEntryType.Information); 88 | } 89 | 90 | /// 91 | /// Logs a Debug message and exception. 92 | /// 93 | /// The message. 94 | /// The exception. 95 | public void Debug(object message, Exception exception) 96 | { 97 | Write("DEBUG: " + message, exception, EventLogEntryType.Information); 98 | } 99 | 100 | /// 101 | /// Logs a Debug format message. 102 | /// 103 | /// The format. 104 | /// The args. 105 | public void DebugFormat(string format, params object[] args) 106 | { 107 | Write("DEBUG: " + string.Format(format, args), EventLogEntryType.Information); 108 | } 109 | 110 | /// 111 | /// Logs a Error message. 112 | /// 113 | /// The message. 114 | public void Error(object message) 115 | { 116 | Write("ERROR: " + message, EventLogEntryType.Error); 117 | } 118 | 119 | /// 120 | /// Logs a Error message and exception. 121 | /// 122 | /// The message. 123 | /// The exception. 124 | public void Error(object message, Exception exception) 125 | { 126 | Write("ERROR: " + message, exception, EventLogEntryType.Error); 127 | } 128 | 129 | /// 130 | /// Logs a Error format message. 131 | /// 132 | /// The format. 133 | /// The args. 134 | public void ErrorFormat(string format, params object[] args) 135 | { 136 | Write("ERROR: " + string.Format(format, args), EventLogEntryType.Error); 137 | } 138 | 139 | /// 140 | /// Logs a Fatal message. 141 | /// 142 | /// The message. 143 | public void Fatal(object message) 144 | { 145 | Write("FATAL: " + message, EventLogEntryType.Error); 146 | } 147 | 148 | /// 149 | /// Logs a Fatal message and exception. 150 | /// 151 | /// The message. 152 | /// The exception. 153 | public void Fatal(object message, Exception exception) 154 | { 155 | Write("FATAL: " + message, exception, EventLogEntryType.Error); 156 | } 157 | 158 | /// 159 | /// Logs a Error format message. 160 | /// 161 | /// The format. 162 | /// The args. 163 | public void FatalFormat(string format, params object[] args) 164 | { 165 | Write("FATAL: " + string.Format(format, args), EventLogEntryType.Error); 166 | } 167 | 168 | /// 169 | /// Logs an Info message and exception. 170 | /// 171 | /// The message. 172 | public void Info(object message) 173 | { 174 | Write("INFO: " + message, EventLogEntryType.Information); 175 | } 176 | 177 | /// 178 | /// Logs an Info message and exception. 179 | /// 180 | /// The message. 181 | /// The exception. 182 | public void Info(object message, Exception exception) 183 | { 184 | Write("INFO: " + message, exception, EventLogEntryType.Information); 185 | } 186 | 187 | /// 188 | /// Logs an Info format message. 189 | /// 190 | /// The format. 191 | /// The args. 192 | public void InfoFormat(string format, params object[] args) 193 | { 194 | Write("INFO: " + string.Format(format, args), EventLogEntryType.Information); 195 | } 196 | 197 | /// 198 | /// Logs a Warning message. 199 | /// 200 | /// The message. 201 | public void Warn(object message) 202 | { 203 | Write("WARN: " + message, EventLogEntryType.Warning); 204 | } 205 | 206 | /// 207 | /// Logs a Warning message and exception. 208 | /// 209 | /// The message. 210 | /// The exception. 211 | public void Warn(object message, Exception exception) 212 | { 213 | Write("WARN: " + message, exception, EventLogEntryType.Warning); 214 | } 215 | 216 | /// 217 | /// Logs a Warning format message. 218 | /// 219 | /// The format. 220 | /// The args. 221 | public void WarnFormat(string format, params object[] args) 222 | { 223 | Write("WARN: " + string.Format(format, args), EventLogEntryType.Warning); 224 | } 225 | 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /tests/ServiceStack.Logging.Tests/ServiceStack.Logging.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {DDDA27EC-5855-4E89-9971-C117EC08BDE3} 9 | Library 10 | Properties 11 | ServiceStack.Logging.Tests 12 | ServiceStack.Logging.Tests 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 3.5 24 | 25 | 26 | false 27 | v4.0 28 | publish\ 29 | true 30 | Disk 31 | false 32 | Foreground 33 | 7 34 | Days 35 | false 36 | false 37 | true 38 | 0 39 | 1.0.0.%2a 40 | false 41 | true 42 | 43 | ..\..\src\ 44 | true 45 | 46 | 47 | true 48 | full 49 | false 50 | bin\Debug\ 51 | DEBUG;TRACE 52 | prompt 53 | 4 54 | AllRules.ruleset 55 | 56 | 57 | pdbonly 58 | true 59 | bin\Release\ 60 | TRACE 61 | prompt 62 | 4 63 | AllRules.ruleset 64 | 65 | 66 | 67 | ..\..\src\packages\log4net.2.0.0\lib\net35-full\log4net.dll 68 | 69 | 70 | False 71 | ..\..\src\packages\EnterpriseLibrary.Common.5.0.505.0\lib\NET35\Microsoft.Practices.EnterpriseLibrary.Common.dll 72 | 73 | 74 | False 75 | ..\..\src\packages\EnterpriseLibrary.Logging.5.0.505.1\lib\NET35\Microsoft.Practices.EnterpriseLibrary.Logging.dll 76 | 77 | 78 | ..\..\src\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll 79 | 80 | 81 | ..\..\src\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll 82 | 83 | 84 | ..\..\src\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll 85 | 86 | 87 | ..\..\src\packages\Unity.Interception.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Interception.dll 88 | 89 | 90 | ..\..\src\packages\Unity.Interception.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Interception.Configuration.dll 91 | 92 | 93 | False 94 | ..\..\src\packages\NLog.2.0.1.2\lib\net35\NLog.dll 95 | 96 | 97 | False 98 | ..\..\src\packages\NUnit.2.6.2\lib\nunit.framework.dll 99 | 100 | 101 | ..\..\src\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll 102 | 103 | 104 | False 105 | ..\..\src\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Common.dll 106 | 107 | 108 | False 109 | ..\..\src\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Interfaces.dll 110 | 111 | 112 | False 113 | ..\..\src\packages\ServiceStack.Text.3.9.59\lib\net35\ServiceStack.Text.dll 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | False 142 | .NET Framework 3.5 SP1 Client Profile 143 | false 144 | 145 | 146 | False 147 | .NET Framework 2.0 %28x86%29 148 | true 149 | 150 | 151 | False 152 | .NET Framework 3.0 %28x86%29 153 | false 154 | 155 | 156 | False 157 | .NET Framework 3.5 158 | false 159 | 160 | 161 | False 162 | .NET Framework 3.5 SP1 163 | false 164 | 165 | 166 | 167 | 168 | {EE43BF1E-CF97-4215-A5A3-46D1C363F928} 169 | ServiceStack.Logging.Elmah 170 | 171 | 172 | {edd72adc-327c-4152-b84b-b48552311534} 173 | ServiceStack.Logging.EntLib5 174 | 175 | 176 | {D920BA88-E394-4C75-94E3-78D7298A8457} 177 | ServiceStack.Logging.EventLog 178 | 179 | 180 | {C44A6E80-326E-4036-8906-62E881F4727D} 181 | ServiceStack.Logging.Log4Net 182 | 183 | 184 | 185 | 186 | Always 187 | 188 | 189 | Always 190 | Designer 191 | 192 | 193 | 194 | 195 | 196 | 197 | 204 | -------------------------------------------------------------------------------- /src/ServiceStack.Logging.EntLib5/EntLib5Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using Microsoft.Practices.EnterpriseLibrary.Logging; 4 | 5 | namespace ServiceStack.Logging.EntLib5 6 | { 7 | /// Wrapper over the Enterprise Library 5.0 Logging Application Block 8 | public class EntLib5Logger : ILog 9 | { 10 | private readonly LogWriter logWriter; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public EntLib5Logger() 16 | { 17 | var factory = new EntLib5Factory(); 18 | logWriter = factory.CreateDefault(); 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The type name. 25 | public EntLib5Logger(string typeName) 26 | { 27 | var factory = new EntLib5Factory(); 28 | logWriter = factory.CreateDefault(); 29 | logWriter.SetContextItem("type", typeName); 30 | } 31 | 32 | /// 33 | /// Initializes a new instance of the class. 34 | /// 35 | /// The type. 36 | public EntLib5Logger(Type type) 37 | { 38 | var factory = new EntLib5Factory(); 39 | logWriter = factory.CreateDefault(); 40 | logWriter.SetContextItem("type", type.Name); 41 | } 42 | 43 | 44 | /// 45 | /// Specifies whether the Debug listener this functional 46 | /// 47 | public bool IsDebugEnabled 48 | { 49 | get 50 | { 51 | #if DEBUG 52 | return true; 53 | #else 54 | return false; 55 | #endif 56 | } 57 | } 58 | 59 | #region DEBUG Handlers 60 | 61 | /// 62 | /// Logs a Debug message. 63 | /// 64 | /// The message. 65 | public void Debug(object message) 66 | { 67 | if (IsDebugEnabled) 68 | { 69 | System.Diagnostics.Debug.WriteLine(message); 70 | } 71 | else 72 | { 73 | if (logWriter.IsLoggingEnabled()) 74 | WriteMessage(message, TraceEventType.Verbose, null, null); 75 | } 76 | } 77 | 78 | /// 79 | /// Logs a Debug message and category. 80 | /// 81 | /// The message. 82 | /// The category. 83 | public void Debug(object message, string category) 84 | { 85 | if (IsDebugEnabled) 86 | { 87 | System.Diagnostics.Debug.WriteLine(message, category); 88 | } 89 | else 90 | { 91 | if (logWriter.IsLoggingEnabled()) 92 | WriteMessage(message, TraceEventType.Verbose, category, null); 93 | } 94 | } 95 | 96 | /// 97 | /// Logs a Debug message and exception. 98 | /// 99 | /// The message. 100 | /// The exception. 101 | public void Debug(object message, Exception exception) 102 | { 103 | if (IsDebugEnabled) 104 | { 105 | System.Diagnostics.Debug.WriteLine(message); 106 | } 107 | else 108 | { 109 | if (logWriter.IsLoggingEnabled()) 110 | WriteMessage(message, TraceEventType.Verbose, null, exception); 111 | } 112 | } 113 | 114 | /// 115 | /// Logs a Debug message, category and exception. 116 | /// 117 | /// The message. 118 | /// The category. 119 | /// The exception. 120 | public void Debug(object message, string category, Exception exception) 121 | { 122 | if (IsDebugEnabled) 123 | { 124 | System.Diagnostics.Debug.WriteLine(message, category); 125 | } 126 | else 127 | { 128 | if (logWriter.IsLoggingEnabled()) 129 | WriteMessage(message, TraceEventType.Verbose, category, exception); 130 | } 131 | } 132 | 133 | /// 134 | /// Logs a Debug format message. 135 | /// 136 | /// The format. 137 | /// The args. 138 | public void DebugFormat(string format, params object[] args) 139 | { 140 | if (IsDebugEnabled) 141 | { 142 | System.Diagnostics.Debug.Print(format, args); 143 | } 144 | else 145 | { 146 | throw new NotSupportedException("The DebugFormat method is not supported. Modify the Log Message Format using a formatter in the loggingConfiguration section."); 147 | } 148 | } 149 | 150 | #endregion 151 | 152 | #region ERROR Handlers 153 | 154 | /// 155 | /// Logs an Error message. 156 | /// 157 | /// The message. 158 | public void Error(object message) 159 | { 160 | if (logWriter.IsLoggingEnabled()) 161 | { 162 | WriteMessage(message, TraceEventType.Error, null, null); 163 | } 164 | } 165 | 166 | /// 167 | /// Logs an Error message and category. 168 | /// 169 | /// The message. 170 | /// The category. 171 | public void Error(object message, string category) 172 | { 173 | if (logWriter.IsLoggingEnabled()) 174 | { 175 | WriteMessage(message, TraceEventType.Error, category, null); 176 | } 177 | } 178 | 179 | /// 180 | /// Logs an Error message and exception. 181 | /// 182 | /// The message. 183 | /// The exception. 184 | public void Error(object message, Exception exception) 185 | { 186 | if (logWriter.IsLoggingEnabled()) 187 | { 188 | WriteMessage(message, TraceEventType.Error, null, exception); 189 | } 190 | } 191 | 192 | /// 193 | /// Logs an Error message, category and exception. 194 | /// 195 | /// The message. 196 | /// The category. 197 | /// The exception. 198 | public void Error(object message, string category, Exception exception) 199 | { 200 | if (logWriter.IsLoggingEnabled()) 201 | { 202 | WriteMessage(message, TraceEventType.Error, category, exception); 203 | } 204 | } 205 | 206 | /// 207 | /// Logs a Error format message. 208 | /// 209 | /// The format. 210 | /// The args. 211 | public void ErrorFormat(string format, params object[] args) 212 | { 213 | if (logWriter.IsLoggingEnabled()) 214 | { 215 | throw new NotSupportedException("The ErrorFormat method is not supported. Modify the Log Message Format using a formatter in the loggingConfiguration section."); 216 | } 217 | } 218 | 219 | #endregion 220 | 221 | #region FATAL Handlers 222 | 223 | /// 224 | /// Logs a Fatal Error message. 225 | /// 226 | /// The message. 227 | public void Fatal(object message) 228 | { 229 | if (logWriter.IsLoggingEnabled()) 230 | { 231 | WriteMessage(message, TraceEventType.Critical, null, null); 232 | } 233 | } 234 | 235 | /// 236 | /// Logs a Fatal Error message and category. 237 | /// 238 | /// The message. 239 | /// The category. 240 | public void Fatal(object message, string category) 241 | { 242 | if (logWriter.IsLoggingEnabled()) 243 | { 244 | WriteMessage(message, TraceEventType.Critical, category, null); 245 | } 246 | } 247 | 248 | /// 249 | /// Logs a Fatal Error message and exception. 250 | /// 251 | /// The message. 252 | /// The exception. 253 | public void Fatal(object message, Exception exception) 254 | { 255 | if (logWriter.IsLoggingEnabled()) 256 | { 257 | WriteMessage(message, TraceEventType.Critical, null, exception); 258 | } 259 | } 260 | 261 | /// 262 | /// Logs a Fatal Error message, category and exception. 263 | /// 264 | /// The message. 265 | /// The category. 266 | /// The exception. 267 | public void Fatal(object message, string category, Exception exception) 268 | { 269 | if (logWriter.IsLoggingEnabled()) 270 | { 271 | WriteMessage(message, TraceEventType.Critical, category, exception); 272 | } 273 | } 274 | 275 | /// 276 | /// Logs a Error format message. 277 | /// 278 | /// The format. 279 | /// The args. 280 | public void FatalFormat(string format, params object[] args) 281 | { 282 | if (logWriter.IsLoggingEnabled()) 283 | { 284 | throw new NotSupportedException("The FatalFormat method is not supported. Modify the Log Message Format using a formatter in the loggingConfiguration section."); 285 | } 286 | } 287 | 288 | #endregion 289 | 290 | #region INFO Handlers 291 | 292 | /// 293 | /// Logs an Info message. 294 | /// 295 | /// The message. 296 | public void Info(object message) 297 | { 298 | if (logWriter.IsLoggingEnabled()) 299 | { 300 | WriteMessage(message, TraceEventType.Information, null, null); 301 | } 302 | } 303 | 304 | /// 305 | /// Logs an Info message and category. 306 | /// 307 | /// The message. 308 | /// The category. 309 | public void Info(object message, string category) 310 | { 311 | if (logWriter.IsLoggingEnabled()) 312 | { 313 | WriteMessage(message, TraceEventType.Information, category, null); 314 | } 315 | } 316 | 317 | /// 318 | /// Logs an Info message and exception. 319 | /// 320 | /// The message. 321 | /// The exception. 322 | public void Info(object message, Exception exception) 323 | { 324 | if (logWriter.IsLoggingEnabled()) 325 | { 326 | WriteMessage(message, TraceEventType.Information, null, exception); 327 | } 328 | } 329 | 330 | /// 331 | /// Logs an Info message, category and exception. 332 | /// 333 | /// The message. 334 | /// The category. 335 | /// The exception. 336 | public void Info(object message, string category, Exception exception) 337 | { 338 | if (logWriter.IsLoggingEnabled()) 339 | { 340 | WriteMessage(message, TraceEventType.Information, category, exception); 341 | } 342 | } 343 | 344 | /// 345 | /// Logs an Info format message. 346 | /// 347 | /// The format. 348 | /// The args. 349 | public void InfoFormat(string format, params object[] args) 350 | { 351 | if (logWriter.IsLoggingEnabled()) 352 | { 353 | throw new NotSupportedException("The InfoFormat method is not supported. Modify the Log Message Format using a formatter in the loggingConfiguration section."); 354 | } 355 | } 356 | 357 | #endregion 358 | 359 | #region WARN Handlers 360 | 361 | /// 362 | /// Logs a Warning message. 363 | /// 364 | /// The message. 365 | public void Warn(object message) 366 | { 367 | if (logWriter.IsLoggingEnabled()) 368 | { 369 | WriteMessage(message, TraceEventType.Warning, null, null); 370 | } 371 | } 372 | 373 | /// 374 | /// Logs a Warning message and category. 375 | /// 376 | /// The message. 377 | /// The category. 378 | public void Warn(object message, string category) 379 | { 380 | if (logWriter.IsLoggingEnabled()) 381 | { 382 | WriteMessage(message, TraceEventType.Warning, category, null); 383 | } 384 | } 385 | 386 | /// 387 | /// Logs a Warning message and exception. 388 | /// 389 | /// The message. 390 | /// The exception. 391 | public void Warn(object message, Exception exception) 392 | { 393 | if (logWriter.IsLoggingEnabled()) 394 | { 395 | WriteMessage(message, TraceEventType.Warning, null, exception); 396 | } 397 | } 398 | 399 | /// 400 | /// Logs a Warning message, category and exception. 401 | /// 402 | /// The message. 403 | /// The category. 404 | /// The exception. 405 | public void Warn(object message, string category, Exception exception) 406 | { 407 | if (logWriter.IsLoggingEnabled()) 408 | { 409 | WriteMessage(message, TraceEventType.Warning, category, exception); 410 | } 411 | } 412 | 413 | /// 414 | /// Logs a Warning format message. 415 | /// 416 | /// The format. 417 | /// The args. 418 | public void WarnFormat(string format, params object[] args) 419 | { 420 | if (logWriter.IsLoggingEnabled()) 421 | { 422 | throw new NotSupportedException("The WarnFormat method is not supported. Modify the Log Message Format using a formatter in the loggingConfiguration section."); 423 | } 424 | } 425 | 426 | #endregion 427 | 428 | private void WriteMessage(object message, TraceEventType eventType, object category = null, Exception exception = null) 429 | { 430 | var entry = new LogEntry(); 431 | entry.Severity = eventType; 432 | 433 | //Add Message 434 | if (message != null) 435 | entry.Message = message.ToString(); 436 | 437 | //Add category 438 | if (category != null) 439 | entry.Categories.Add(category.ToString()); 440 | 441 | //Add exception, user name, detailed date & time if needed 442 | entry.ExtendedProperties.Add("Exception", exception); 443 | entry.TimeStamp = DateTime.UtcNow; 444 | 445 | logWriter.Write(entry); 446 | } 447 | } 448 | } 449 | --------------------------------------------------------------------------------