summaryrefslogtreecommitdiff
path: root/src/Notepad/Infrastructure/Logging/Log4NetLogging
diff options
context:
space:
mode:
Diffstat (limited to 'src/Notepad/Infrastructure/Logging/Log4NetLogging')
-rw-r--r--src/Notepad/Infrastructure/Logging/Log4NetLogging/Log4NetLogFactory.cs20
-rw-r--r--src/Notepad/Infrastructure/Logging/Log4NetLogging/Log4NetLogger.cs20
2 files changed, 40 insertions, 0 deletions
diff --git a/src/Notepad/Infrastructure/Logging/Log4NetLogging/Log4NetLogFactory.cs b/src/Notepad/Infrastructure/Logging/Log4NetLogging/Log4NetLogFactory.cs
new file mode 100644
index 0000000..0784a13
--- /dev/null
+++ b/src/Notepad/Infrastructure/Logging/Log4NetLogging/Log4NetLogFactory.cs
@@ -0,0 +1,20 @@
+using System;
+using System.IO;
+using log4net;
+using log4net.Config;
+
+namespace Notepad.Infrastructure.Logging.Log4NetLogging {
+ public class Log4NetLogFactory : ILogFactory {
+ public Log4NetLogFactory() {
+ XmlConfigurator.Configure(PathToConfigFile());
+ }
+
+ public ILogger CreateFor(Type typeToCreateLoggerFor) {
+ return new Log4NetLogger(LogManager.GetLogger(typeToCreateLoggerFor));
+ }
+
+ private FileInfo PathToConfigFile() {
+ return new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config.xml"));
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Notepad/Infrastructure/Logging/Log4NetLogging/Log4NetLogger.cs b/src/Notepad/Infrastructure/Logging/Log4NetLogging/Log4NetLogger.cs
new file mode 100644
index 0000000..5111622
--- /dev/null
+++ b/src/Notepad/Infrastructure/Logging/Log4NetLogging/Log4NetLogger.cs
@@ -0,0 +1,20 @@
+using System;
+using log4net;
+
+namespace Notepad.Infrastructure.Logging.Log4NetLogging {
+ public class Log4NetLogger : ILogger {
+ private readonly ILog log;
+
+ public Log4NetLogger(ILog log) {
+ this.log = log;
+ }
+
+ public void Informational(string formattedString, params object[] arguments) {
+ log.InfoFormat(formattedString, arguments);
+ }
+
+ public void Error(Exception e) {
+ log.Error(e.ToString());
+ }
+ }
+} \ No newline at end of file