Skip to content

Commit 65fc850

Browse files
committed
Merge pull request #7 from alexandrerocco/master
Fixed issues with log4net 1.2.10
2 parents a542932 + 73be576 commit 65fc850

8 files changed

Lines changed: 458 additions & 0 deletions

File tree

lib/log4net.1.2.10.dll

264 KB
Binary file not shown.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using System.IO;
3+
4+
namespace ServiceStack.Logging.Log4Net
5+
{
6+
/// <summary>
7+
/// ILogFactory that creates an Log4Net ILog logger
8+
/// </summary>
9+
public class Log4NetFactory : ILogFactory
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="Log4NetFactory"/> class.
13+
/// </summary>
14+
public Log4NetFactory() : this(false) { }
15+
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="Log4NetFactory"/> class.
18+
/// </summary>
19+
/// <param name="configureLog4Net">if set to <c>true</c> [will use the xml definition in App.Config to configure log4 net].</param>
20+
public Log4NetFactory(bool configureLog4Net)
21+
{
22+
if (configureLog4Net)
23+
{
24+
log4net.Config.XmlConfigurator.Configure();
25+
}
26+
}
27+
28+
/// <summary>
29+
/// Initializes a new instance of the <see cref="Log4NetFactory"/> class.
30+
/// </summary>
31+
/// <param name="log4NetConfigurationFile">The log4 net configuration file to load and watch. If not found configures from App.Config.</param>
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+
/// <summary>
46+
/// Gets the logger.
47+
/// </summary>
48+
/// <param name="type">The type.</param>
49+
/// <returns></returns>
50+
public ILog GetLogger(Type type)
51+
{
52+
return new Log4NetLogger(type);
53+
}
54+
55+
/// <summary>
56+
/// Gets the logger.
57+
/// </summary>
58+
/// <param name="typeName">Name of the type.</param>
59+
/// <returns></returns>
60+
public ILog GetLogger(string typeName)
61+
{
62+
return new Log4NetLogger(typeName);
63+
}
64+
}
65+
}
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
using System;
2+
3+
namespace ServiceStack.Logging.Log4Net
4+
{
5+
/// <summary>
6+
/// Wrapper over the log4net.1.2.10 and above logger
7+
/// </summary>
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+
/// <summary>
18+
/// Initializes a new instance of the <see cref="Log4NetLogger"/> class.
19+
/// </summary>
20+
/// <param name="type">The type.</param>
21+
public Log4NetLogger(Type type)
22+
{
23+
_log = log4net.LogManager.GetLogger(type);
24+
}
25+
26+
public bool IsDebugEnabled { get { return _log.IsDebugEnabled; } }
27+
28+
/// <summary>
29+
/// Logs a Debug message.
30+
/// </summary>
31+
/// <param name="message">The message.</param>
32+
public void Debug(object message)
33+
{
34+
if (_log.IsDebugEnabled)
35+
_log.Debug(message);
36+
}
37+
38+
/// <summary>
39+
/// Logs a Debug message and exception.
40+
/// </summary>
41+
/// <param name="message">The message.</param>
42+
/// <param name="exception">The exception.</param>
43+
public void Debug(object message, Exception exception)
44+
{
45+
if (_log.IsDebugEnabled)
46+
_log.Debug(message, exception);
47+
}
48+
49+
/// <summary>
50+
/// Logs a Debug format message.
51+
/// </summary>
52+
/// <param name="format">The format.</param>
53+
/// <param name="args">The args.</param>
54+
public void DebugFormat(string format, params object[] args)
55+
{
56+
if (_log.IsDebugEnabled)
57+
_log.DebugFormat(format, args);
58+
}
59+
60+
/// <summary>
61+
/// Logs a Error message.
62+
/// </summary>
63+
/// <param name="message">The message.</param>
64+
public void Error(object message)
65+
{
66+
if (_log.IsErrorEnabled)
67+
_log.Error(message);
68+
}
69+
70+
/// <summary>
71+
/// Logs a Error message and exception.
72+
/// </summary>
73+
/// <param name="message">The message.</param>
74+
/// <param name="exception">The exception.</param>
75+
public void Error(object message, Exception exception)
76+
{
77+
if (_log.IsErrorEnabled)
78+
_log.Error(message, exception);
79+
}
80+
81+
/// <summary>
82+
/// Logs a Error format message.
83+
/// </summary>
84+
/// <param name="format">The format.</param>
85+
/// <param name="args">The args.</param>
86+
public void ErrorFormat(string format, params object[] args)
87+
{
88+
if (_log.IsErrorEnabled)
89+
_log.ErrorFormat(format, args);
90+
}
91+
92+
/// <summary>
93+
/// Logs a Fatal message.
94+
/// </summary>
95+
/// <param name="message">The message.</param>
96+
public void Fatal(object message)
97+
{
98+
if (_log.IsFatalEnabled)
99+
_log.Fatal(message);
100+
}
101+
102+
/// <summary>
103+
/// Logs a Fatal message and exception.
104+
/// </summary>
105+
/// <param name="message">The message.</param>
106+
/// <param name="exception">The exception.</param>
107+
public void Fatal(object message, Exception exception)
108+
{
109+
if (_log.IsFatalEnabled)
110+
_log.Fatal(message, exception);
111+
}
112+
113+
/// <summary>
114+
/// Logs a Error format message.
115+
/// </summary>
116+
/// <param name="format">The format.</param>
117+
/// <param name="args">The args.</param>
118+
public void FatalFormat(string format, params object[] args)
119+
{
120+
if (_log.IsFatalEnabled)
121+
_log.FatalFormat(format, args);
122+
}
123+
124+
/// <summary>
125+
/// Logs an Info message and exception.
126+
/// </summary>
127+
/// <param name="message">The message.</param>
128+
public void Info(object message)
129+
{
130+
if (_log.IsInfoEnabled)
131+
_log.Info(message);
132+
}
133+
134+
/// <summary>
135+
/// Logs an Info message and exception.
136+
/// </summary>
137+
/// <param name="message">The message.</param>
138+
/// <param name="exception">The exception.</param>
139+
public void Info(object message, Exception exception)
140+
{
141+
if (_log.IsInfoEnabled)
142+
_log.Info(message, exception);
143+
}
144+
145+
/// <summary>
146+
/// Logs an Info format message.
147+
/// </summary>
148+
/// <param name="format">The format.</param>
149+
/// <param name="args">The args.</param>
150+
public void InfoFormat(string format, params object[] args)
151+
{
152+
if (_log.IsInfoEnabled)
153+
_log.InfoFormat(format, args);
154+
}
155+
156+
/// <summary>
157+
/// Logs a Warning message.
158+
/// </summary>
159+
/// <param name="message">The message.</param>
160+
public void Warn(object message)
161+
{
162+
if (_log.IsWarnEnabled)
163+
_log.Warn(message);
164+
}
165+
166+
/// <summary>
167+
/// Logs a Warning message and exception.
168+
/// </summary>
169+
/// <param name="message">The message.</param>
170+
/// <param name="exception">The exception.</param>
171+
public void Warn(object message, Exception exception)
172+
{
173+
if (_log.IsWarnEnabled)
174+
_log.Warn(message, exception);
175+
}
176+
177+
/// <summary>
178+
/// Logs a Warning format message.
179+
/// </summary>
180+
/// <param name="format">The format.</param>
181+
/// <param name="args">The args.</param>
182+
public void WarnFormat(string format, params object[] args)
183+
{
184+
if (_log.IsWarnEnabled)
185+
_log.WarnFormat(format, args);
186+
}
187+
}
188+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 2012")]
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.3")]
40+
[assembly: AssemblyFileVersion("1.0.3")]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
4+
<id>$id$</id>
5+
<version>$version$</version>
6+
<title>$title$</title>
7+
<authors>$author$</authors>
8+
<owners>$author$</owners>
9+
<summary>log4Net 1.2.10 logging integration for ServiceStack, the Opensource .NET and Mono REST Web Services Framework</summary>
10+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<description>$description$</description>
12+
<projectUrl>https://github.com/ServiceStack/ServiceStack.Logging</projectUrl>
13+
<licenseUrl>https://github.com/ServiceStack/ServiceStack/blob/master/LICENSE</licenseUrl>
14+
<iconUrl>http://www.servicestack.net/logo-100x100.png</iconUrl>
15+
<tags>servicestack log logging log4net</tags>
16+
<language>en-US</language>
17+
<copyright>servicestack.net 2012 and contributors</copyright>
18+
<dependencies>
19+
<dependency id="log4net" version="1.2.10" />
20+
<dependency id="ServiceStack.Common" />
21+
</dependencies>
22+
</metadata>
23+
</package>

0 commit comments

Comments
 (0)