forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsingEntLib5.cs
More file actions
40 lines (34 loc) · 1.38 KB
/
Copy pathUsingEntLib5.cs
File metadata and controls
40 lines (34 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using NUnit.Framework;
using ServiceStack.Logging.EntLib5;
namespace ServiceStack.Logging.Tests.UseCases
{
[TestFixture]
public class UsingEntLib5
{
[Test]
public void EntLib5UseCase()
{
// construct the Configuration Source to use
var builder = new ConfigurationSourceBuilder();
// fluent API configuration
builder.ConfigureLogging()
.WithOptions
.DoNotRevertImpersonation()
.LogToCategoryNamed("Simple")
.SendTo.FlatFile("Simple Log File")
.FormatWith(new FormatterBuilder()
.TextFormatterNamed("simpleFormat")
.UsingTemplate("{timestamp} : {message}{newline}"))
.ToFile("simple.log");
var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current
= EnterpriseLibraryContainer.CreateDefaultContainer(configSource);
LogManager.LogFactory = new EntLib5Factory(configSource);
ILog log = LogManager.GetLogger(GetType());
log.Debug("Debug Event Log Entry.");
log.Warn("Warning Event Log Entry.");
}
}
}