Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from alexandrerocco/master
Fixed issues with log4net 1.2.10
- Loading branch information
Showing
8 changed files
with
458 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace ServiceStack.Logging.Log4Net | ||
{ | ||
/// <summary> | ||
/// ILogFactory that creates an Log4Net ILog logger | ||
/// </summary> | ||
public class Log4NetFactory : ILogFactory | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Log4NetFactory"/> class. | ||
/// </summary> | ||
public Log4NetFactory() : this(false) { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Log4NetFactory"/> class. | ||
/// </summary> | ||
/// <param name="configureLog4Net">if set to <c>true</c> [will use the xml definition in App.Config to configure log4 net].</param> | ||
public Log4NetFactory(bool configureLog4Net) | ||
{ | ||
if (configureLog4Net) | ||
{ | ||
log4net.Config.XmlConfigurator.Configure(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Log4NetFactory"/> class. | ||
/// </summary> | ||
/// <param name="log4NetConfigurationFile">The log4 net configuration file to load and watch. If not found configures from App.Config.</param> | ||
public Log4NetFactory(string log4NetConfigurationFile) | ||
{ | ||
//Restart logging if necessary | ||
log4net.Repository.ILoggerRepository rootRepository = log4net.LogManager.GetRepository(); | ||
if (rootRepository != null) | ||
rootRepository.Shutdown(); | ||
|
||
if (File.Exists(log4NetConfigurationFile)) | ||
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(log4NetConfigurationFile)); | ||
else | ||
log4net.Config.XmlConfigurator.Configure(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the logger. | ||
/// </summary> | ||
/// <param name="type">The type.</param> | ||
/// <returns></returns> | ||
public ILog GetLogger(Type type) | ||
{ | ||
return new Log4NetLogger(type); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the logger. | ||
/// </summary> | ||
/// <param name="typeName">Name of the type.</param> | ||
/// <returns></returns> | ||
public ILog GetLogger(string typeName) | ||
{ | ||
return new Log4NetLogger(typeName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
using System; | ||
|
||
namespace ServiceStack.Logging.Log4Net | ||
{ | ||
/// <summary> | ||
/// Wrapper over the log4net.1.2.10 and above logger | ||
/// </summary> | ||
public class Log4NetLogger : ILog | ||
{ | ||
private readonly log4net.ILog _log; | ||
|
||
public Log4NetLogger(string typeName) | ||
{ | ||
_log = log4net.LogManager.GetLogger(typeName); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Log4NetLogger"/> class. | ||
/// </summary> | ||
/// <param name="type">The type.</param> | ||
public Log4NetLogger(Type type) | ||
{ | ||
_log = log4net.LogManager.GetLogger(type); | ||
} | ||
|
||
public bool IsDebugEnabled { get { return _log.IsDebugEnabled; } } | ||
|
||
/// <summary> | ||
/// Logs a Debug message. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
public void Debug(object message) | ||
{ | ||
if (_log.IsDebugEnabled) | ||
_log.Debug(message); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Debug message and exception. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
/// <param name="exception">The exception.</param> | ||
public void Debug(object message, Exception exception) | ||
{ | ||
if (_log.IsDebugEnabled) | ||
_log.Debug(message, exception); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Debug format message. | ||
/// </summary> | ||
/// <param name="format">The format.</param> | ||
/// <param name="args">The args.</param> | ||
public void DebugFormat(string format, params object[] args) | ||
{ | ||
if (_log.IsDebugEnabled) | ||
_log.DebugFormat(format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Error message. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
public void Error(object message) | ||
{ | ||
if (_log.IsErrorEnabled) | ||
_log.Error(message); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Error message and exception. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
/// <param name="exception">The exception.</param> | ||
public void Error(object message, Exception exception) | ||
{ | ||
if (_log.IsErrorEnabled) | ||
_log.Error(message, exception); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Error format message. | ||
/// </summary> | ||
/// <param name="format">The format.</param> | ||
/// <param name="args">The args.</param> | ||
public void ErrorFormat(string format, params object[] args) | ||
{ | ||
if (_log.IsErrorEnabled) | ||
_log.ErrorFormat(format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Fatal message. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
public void Fatal(object message) | ||
{ | ||
if (_log.IsFatalEnabled) | ||
_log.Fatal(message); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Fatal message and exception. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
/// <param name="exception">The exception.</param> | ||
public void Fatal(object message, Exception exception) | ||
{ | ||
if (_log.IsFatalEnabled) | ||
_log.Fatal(message, exception); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Error format message. | ||
/// </summary> | ||
/// <param name="format">The format.</param> | ||
/// <param name="args">The args.</param> | ||
public void FatalFormat(string format, params object[] args) | ||
{ | ||
if (_log.IsFatalEnabled) | ||
_log.FatalFormat(format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Logs an Info message and exception. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
public void Info(object message) | ||
{ | ||
if (_log.IsInfoEnabled) | ||
_log.Info(message); | ||
} | ||
|
||
/// <summary> | ||
/// Logs an Info message and exception. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
/// <param name="exception">The exception.</param> | ||
public void Info(object message, Exception exception) | ||
{ | ||
if (_log.IsInfoEnabled) | ||
_log.Info(message, exception); | ||
} | ||
|
||
/// <summary> | ||
/// Logs an Info format message. | ||
/// </summary> | ||
/// <param name="format">The format.</param> | ||
/// <param name="args">The args.</param> | ||
public void InfoFormat(string format, params object[] args) | ||
{ | ||
if (_log.IsInfoEnabled) | ||
_log.InfoFormat(format, args); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Warning message. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
public void Warn(object message) | ||
{ | ||
if (_log.IsWarnEnabled) | ||
_log.Warn(message); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Warning message and exception. | ||
/// </summary> | ||
/// <param name="message">The message.</param> | ||
/// <param name="exception">The exception.</param> | ||
public void Warn(object message, Exception exception) | ||
{ | ||
if (_log.IsWarnEnabled) | ||
_log.Warn(message, exception); | ||
} | ||
|
||
/// <summary> | ||
/// Logs a Warning format message. | ||
/// </summary> | ||
/// <param name="format">The format.</param> | ||
/// <param name="args">The args.</param> | ||
public void WarnFormat(string format, params object[] args) | ||
{ | ||
if (_log.IsWarnEnabled) | ||
_log.WarnFormat(format, args); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/ServiceStack.Logging.Log4Netv1210/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("ServiceStack.Logging.Log4Net")] | ||
[assembly: AssemblyDescription(@"Provides log4net logging integration for other ServiceStack projects | ||
Includes: | ||
- ServiceStack.Logging.Log4Net.dll | ||
Dependencies: | ||
- ServiceStack.Interfaces.dll")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Demis Bellot")] | ||
[assembly: AssemblyProduct("ServiceStack.Logging.Log4Net")] | ||
[assembly: AssemblyCopyright("Copyright © ServiceStack 2012")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("d575bdba-a6db-464c-8c41-bd0694b79b02")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Revision and Build Numbers | ||
// by using the '*' as shown below: | ||
[assembly: AssemblyVersion("1.0.3")] | ||
[assembly: AssemblyFileVersion("1.0.3")] |
23 changes: 23 additions & 0 deletions
23
src/ServiceStack.Logging.Log4Netv1210/ServiceStack.Logging.Log4Net.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<id>$id$</id> | ||
<version>$version$</version> | ||
<title>$title$</title> | ||
<authors>$author$</authors> | ||
<owners>$author$</owners> | ||
<summary>log4Net 1.2.10 logging integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework</summary> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>$description$</description> | ||
<projectUrl>https://github.com/ServiceStack/ServiceStack.Logging</projectUrl> | ||
<licenseUrl>https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE</licenseUrl> | ||
<iconUrl>http://www.servicestack.net/logo-100x100.png</iconUrl> | ||
<tags>servicestack log logging log4net</tags> | ||
<language>en-US</language> | ||
<copyright>servicestack.net 2012 and contributors</copyright> | ||
<dependencies> | ||
<dependency id="log4net" version="1.2.10" /> | ||
<dependency id="ServiceStack.Common" /> | ||
</dependencies> | ||
</metadata> | ||
</package> |
Oops, something went wrong.