You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## ServiceStack.Logging an implementation-free logging interface for your app logic to bind to
2
-
3
-
Even in the spirit of **Bind to interfaces, not implemenations**, many .NET projects still have
4
-
a hard dependency to [log4net](http://logging.apache.org/log4net/index.html).
5
-
6
-
Although log4net is the standard for logging in .NET, potential problems can arise from your libraries having a hard dependency on it:
7
-
8
-
* Your library needs to be shipped with a third-party dependency
9
-
* 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).
10
-
* You may want to use a different logging provider (i.e. network distributed logging)
11
-
* You want your logging for Unit and Integration tests to redirect to the Console or Debug logger without any configuraiton.
12
-
13
-
ServiceStack.Logging solves these problems by providing an implementation-free ILog interface that your application logic can bind to
14
-
where your Application Host project can bind to the concrete logging implementation at deploy or runtime.
15
-
16
-
ServiceStack.Logging also includes adapters for the following logging providers:
17
-
18
-
* Log4Net 1.2.10+
19
-
* Log4Net 1.2.9
20
-
* EventLog
21
-
* Console Log
22
-
* Debug Log
23
-
* Null / Empty Log
24
-
25
-
# Usage Examples
26
-
27
-
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.
28
-
29
-
## Log4Net
30
-
LogManager.LogFactory = new Log4NetFactory(true); //Also runs log4net.Config.XmlConfigurator.Configure()
31
-
32
-
## Event Log
33
-
LogManager.LogFactory = new EventLogFactory("ServiceStack.Logging.Tests", "Application");
34
-
35
-
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:
36
-
37
-
ILog log = LogManager.GetLogger(GetType());
38
-
39
-
log.Debug("Debug Event Log Entry.");
40
-
log.Warn("Warning Event Log Entry.");
41
-
42
-
43
-
44
-
1
+
## ServiceStack.Logging an implementation-free logging interface for your app logic to bind to
2
+
For twitter updates follow <ahref="http://twitter.com/demisbellot">@demisbellot</a> or <ahref="http://twitter.com/servicestack">@ServiceStack</a>
3
+
4
+
Even in the spirit of **Bind to interfaces, not implemenations**, many .NET projects still have
5
+
a hard dependency to [log4net](http://logging.apache.org/log4net/index.html).
6
+
7
+
Although log4net is the standard for logging in .NET, potential problems can arise from your libraries having a hard dependency on it:
8
+
9
+
* Your library needs to be shipped with a third-party dependency
10
+
* 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).
11
+
* You may want to use a different logging provider (i.e. network distributed logging)
12
+
* You want your logging for Unit and Integration tests to redirect to the Console or Debug logger without any configuraiton.
13
+
14
+
ServiceStack.Logging solves these problems by providing an implementation-free ILog interface that your application logic can bind to
15
+
where your Application Host project can bind to the concrete logging implementation at deploy or runtime.
16
+
17
+
ServiceStack.Logging also includes adapters for the following logging providers:
18
+
19
+
* Log4Net 1.2.10+
20
+
* Log4Net 1.2.9
21
+
* EventLog
22
+
* Console Log
23
+
* Debug Log
24
+
* Null / Empty Log
25
+
26
+
# Usage Examples
27
+
28
+
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.
29
+
30
+
## Log4Net
31
+
LogManager.LogFactory = new Log4NetFactory(true); //Also runs log4net.Config.XmlConfigurator.Configure()
32
+
33
+
## Event Log
34
+
LogManager.LogFactory = new EventLogFactory("ServiceStack.Logging.Tests", "Application");
35
+
36
+
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:
0 commit comments