-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade dependencies & Support Exceptions
NLog 4.2.3 Elasticsearch.Net 1.8.0 Tidy existing code
- Loading branch information
1 parent
899ff0b
commit 6209dd0
Showing
10 changed files
with
233 additions
and
108 deletions.
There are no files selected for viewing
40 changes: 0 additions & 40 deletions
40
src/NLog.Targets.ElasticSearch.Tests/ElasticSearchTargetTests.cs
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using NLog.Config; | ||
using NUnit.Framework; | ||
|
||
namespace NLog.Targets.ElasticSearch.Tests | ||
{ | ||
[TestFixture, Explicit] | ||
public class IntegrationTests | ||
{ | ||
[Test] | ||
public void SimpleLogTest() | ||
{ | ||
var elasticTarget = new ElasticSearchTarget(); | ||
|
||
var rule = new LoggingRule("*", elasticTarget); | ||
rule.EnableLoggingForLevel(LogLevel.Info); | ||
|
||
var config = new LoggingConfiguration(); | ||
config.LoggingRules.Add(rule); | ||
|
||
LogManager.Configuration = config; | ||
|
||
var logger = LogManager.GetLogger("Example"); | ||
|
||
logger.Info("Hello elasticsearch"); | ||
|
||
LogManager.Flush(); | ||
} | ||
|
||
[Test] | ||
public void ExceptionTest() | ||
{ | ||
var elasticTarget = new ElasticSearchTarget(); | ||
|
||
var rule = new LoggingRule("*", elasticTarget); | ||
rule.EnableLoggingForLevel(LogLevel.Error); | ||
|
||
var config = new LoggingConfiguration(); | ||
config.LoggingRules.Add(rule); | ||
|
||
LogManager.Configuration = config; | ||
|
||
var logger = LogManager.GetLogger("Example"); | ||
|
||
var exception = new ArgumentNullException("argument"); | ||
|
||
logger.Error(exception, "An exception occured"); | ||
|
||
LogManager.Flush(); | ||
} | ||
|
||
[Test] | ||
public void ReadFromConfigTest() | ||
{ | ||
LogManager.Configuration = new XmlLoggingConfiguration("NLog.Targets.ElasticSearch.Tests.dll.config"); | ||
|
||
var logger = LogManager.GetLogger("Example"); | ||
|
||
logger.Info("Hello elasticsearch"); | ||
|
||
LogManager.Flush(); | ||
} | ||
} | ||
} |
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,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NLog" version="3.1.0.0" targetFramework="net40" /> | ||
<package id="NUnit" version="2.6.3" targetFramework="net40" /> | ||
<package id="NLog" version="4.2.3" targetFramework="net40" /> | ||
<package id="NUnit" version="3.2.0" targetFramework="net40" /> | ||
</packages> |
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
Oops, something went wrong.