Skip to content

Commit af26b1b

Browse files
committed
Testing log4net appender.
1 parent ea6a822 commit af26b1b

File tree

6 files changed

+25
-2
lines changed

6 files changed

+25
-2
lines changed

Source/Platforms/Log4net/ExceptionlessAppender.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ public class ExceptionlessAppender : AppenderSkeleton {
1212
public override void ActivateOptions() {
1313
if (!String.IsNullOrEmpty(ApiKey) || !String.IsNullOrEmpty(ServerUrl))
1414
_client = new ExceptionlessClient(config => {
15-
config.ApiKey = ApiKey;
16-
config.ServerUrl = ServerUrl;
15+
if (!String.IsNullOrEmpty(ApiKey))
16+
config.ApiKey = ApiKey;
17+
if (!String.IsNullOrEmpty(ServerUrl))
18+
config.ServerUrl = ServerUrl;
1719
config.UseInMemoryStorage();
1820
});
1921
else

Source/Samples/SampleConsole/Exceptionless.SampleConsole.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
<Reference Include="Exceptionless.RandomData">
5252
<HintPath>..\..\..\packages\Exceptionless.RandomData.1.0.4.0\lib\net40\Exceptionless.RandomData.dll</HintPath>
5353
</Reference>
54+
<Reference Include="log4net">
55+
<HintPath>..\..\..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
56+
</Reference>
5457
<Reference Include="NLog">
5558
<HintPath>..\..\..\packages\NLog.3.2.0.0\lib\net45\NLog.dll</HintPath>
5659
</Reference>
@@ -91,6 +94,10 @@
9194
<Project>{693f3cbf-5bc7-457d-9f31-bdd89c72677e}</Project>
9295
<Name>Exceptionless.Extras</Name>
9396
</ProjectReference>
97+
<ProjectReference Include="..\..\Platforms\Log4net\Exceptionless.Log4net.csproj">
98+
<Project>{c3411d82-a4c9-41af-99b8-f71926d69fd1}</Project>
99+
<Name>Exceptionless.Log4net</Name>
100+
</ProjectReference>
94101
<ProjectReference Include="..\..\Platforms\NLog\Exceptionless.NLog.csproj">
95102
<Project>{5eb81eef-ed35-4ad2-9b20-0b3e5c94bba4}</Project>
96103
<Name>Exceptionless.NLog</Name>

Source/Samples/SampleConsole/Program.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
using Exceptionless.Dependency;
2020
using Exceptionless.Extensions;
2121
using Exceptionless.Helpers;
22+
using Exceptionless.Log4net;
2223
using Exceptionless.Logging;
2324
using Exceptionless.Models;
25+
using log4net;
26+
using log4net.Config;
2427
using NLog.Fluent;
2528

2629
namespace SampleConsole {
@@ -29,6 +32,7 @@ internal class Program {
2932
private static int _delayIndex = 2;
3033
private static readonly InMemoryExceptionlessLog _log = new InMemoryExceptionlessLog { MinimumLogLevel = LogLevel.Info };
3134
private static readonly object _writeLock = new object();
35+
private static readonly ILog _log4net = LogManager.GetLogger(typeof(Program));
3236

3337
private static readonly TimeSpan[] _dateSpans = {
3438
TimeSpan.Zero,
@@ -50,8 +54,13 @@ private static void Main() {
5054
//ExceptionlessClient.Default.Configuration.SubmissionBatchSize = 1;
5155
ExceptionlessClient.Default.Register();
5256

57+
// test NLog
5358
Log.Info().Message("Hi").Write();
5459

60+
// test log4net
61+
BasicConfigurator.Configure(new ExceptionlessAppender());
62+
_log4net.Info("Hi");
63+
5564
var tokenSource = new CancellationTokenSource();
5665
CancellationToken token = tokenSource.Token;
5766
if (false)

Source/Samples/SampleConsole/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<packages>
33
<package id="Exceptionless.DateTimeExtensions" version="3.0.33" targetFramework="net451" />
44
<package id="Exceptionless.RandomData" version="1.0.4.0" targetFramework="net451" />
5+
<package id="log4net" version="2.0.3" targetFramework="net451" />
56
<package id="NLog" version="3.2.0.0" targetFramework="net451" />
67
<package id="NLog.Config" version="3.2.0.0" targetFramework="net451" />
78
<package id="NLog.Schema" version="3.2.0.0" targetFramework="net451" />

Source/Tests/Exceptionless.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
4+
<Import Project="..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" />
45
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
56
<PropertyGroup>
67
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -15,6 +16,7 @@
1516
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\..\</SolutionDir>
1617
<TargetFrameworkProfile />
1718
<NuGetPackageImportStamp>25bd791a</NuGetPackageImportStamp>
19+
<NuGetPackageImportStamp>31a90b0c</NuGetPackageImportStamp>
1820
</PropertyGroup>
1921
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2022
<DebugSymbols>true</DebugSymbols>
@@ -158,6 +160,7 @@
158160
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
159161
</PropertyGroup>
160162
<Error Condition="!Exists('..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
163+
<Error Condition="!Exists('..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props'))" />
161164
</Target>
162165
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
163166
Other similar extension points exist, see Microsoft.Common.targets.

Source/Tests/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
<package id="xunit.assert" version="2.0.0" targetFramework="net451" />
2121
<package id="xunit.core" version="2.0.0" targetFramework="net451" />
2222
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net451" />
23+
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net451" />
2324
</packages>

0 commit comments

Comments
 (0)