-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
moberacker
committed
Oct 10, 2018
1 parent
9f16ef6
commit 7284bd5
Showing
12 changed files
with
102 additions
and
66 deletions.
There are no files selected for viewing
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
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
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
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
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
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 |
---|---|---|
@@ -1,52 +1,48 @@ | ||
using log4net; | ||
using System; | ||
using log4net.Config; | ||
using System.IO; | ||
using log4net.Repository; | ||
using System.Reflection; | ||
|
||
namespace Log4ALATest | ||
namespace Log4ALATest.Core | ||
{ | ||
|
||
class LoggerTests | ||
{ | ||
private static ILoggerRepository REPOSITORY = log4net.LogManager.CreateRepository(Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy)); | ||
|
||
private static ILog alaLogger1 = LogManager.GetLogger("Log4ALALogger_1"); | ||
private static ILog alaLogger2 = LogManager.GetLogger("Log4ALALogger_2"); | ||
private static ILog alaLogger3 = LogManager.GetLogger("Log4ALALogger_3"); | ||
private static ILog alaLogger2 = LogManager.GetLogger(REPOSITORY.Name, "Log4ALALogger_2"); | ||
|
||
static void Main(string[] args) | ||
{ | ||
|
||
//Log message as anonymous type... the properties will then be mapped to Azure Log Analytic properties/columns. | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
alaLogger1.Info(new { id = $"log-{i}", message = $"test-{i}" }); | ||
} | ||
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); | ||
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); | ||
|
||
System.Console.WriteLine("done1"); | ||
|
||
//Log messages with semicolon separated key=value strings...the keys will then be mapped to Azure Log Analytic properties/columns. | ||
for (int i = 0; i < 10; i++) | ||
////Log messages with semicolon separated key=value strings...the keys will then be mapped to Azure Log Analytic properties/columns. | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
alaLogger2.Info($"id=log-{i}; message=test-{i}"); | ||
alaLogger2.Info($"id=log-{i}; message=netstandard2-test-{i}; intTest={i}; doubleTest={i}.{5}"); | ||
} | ||
|
||
System.Console.WriteLine("done2"); | ||
|
||
//Log messages with semicolon separated key=value strings and duplicate key detection... the duplicate keys in the following example | ||
//will be mapped to Azur Log Analytic properties/columns message_Duplicate0 and message_Duplicate1. | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
alaLogger2.Info($"id=log-{i}; message=test-{i}; message=test-{i}; message=test-{i}"); | ||
} | ||
System.Console.WriteLine("done"); | ||
|
||
System.Console.WriteLine("done3"); | ||
|
||
//Log message as json string ...the json properties will then be mapped to Azure Log Analytic properties/columns. | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
alaLogger3.Info($"{{\"id\":\"log-{i}\", \"message\":\"test-{i}\"}}"); | ||
} | ||
|
||
System.Console.WriteLine("done4"); | ||
System.Threading.Thread.Sleep(new TimeSpan(0, 0, 20)); | ||
|
||
|
||
//System.Console.WriteLine("shutdown logger..."); | ||
|
||
//LogManager.Shutdown(); | ||
//System.Console.WriteLine("shutdown succeeded..."); | ||
|
||
System.Threading.Thread.Sleep(new TimeSpan(1, 0, 0)); | ||
|
||
|
||
System.Threading.Thread.Sleep(new TimeSpan(0, 5, 0)); | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
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