Skip to content

Commit 52e85e9

Browse files
committed
Updated sample console app configuration
1 parent 4ca3ce0 commit 52e85e9

File tree

6 files changed

+23
-32
lines changed

6 files changed

+23
-32
lines changed
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
11
<?xml version="1.0"?>
22
<configuration>
33
<configSections>
4-
<section name="exceptionless" type="Exceptionless.ExceptionlessSection, Exceptionless"/>
54
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
65
</configSections>
76

8-
<exceptionless apiKey="LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw" serverUrl="http://localhost:50000" tags="Tag1,Tag2">
9-
<settings>
10-
<add name="TraceLogLimit" value="25"/>
11-
<add name="IncludeConditionalData" value="true"/>
12-
</settings>
13-
<data>
14-
<add name="SimpleValueFromConfig" value="Exceptionless"/>
15-
<add name="JsonDataFromConfig" value="{ &quot;Property1&quot;: &quot;Exceptionless&quot;, &quot;Property2&quot;: 10, &quot;Property3&quot;: true }"/>
16-
</data>
17-
<!--<registrations>
18-
<registration service="ISubmissionClient" type="Exceptionless.SampleConsole.InMemorySubmissionClient, SampleConsole" />
19-
</registrations>-->
20-
</exceptionless>
21-
227
<log4net>
238
<appender name="exceptionless" type="Exceptionless.Log4net.ExceptionlessAppender,Exceptionless.Log4net">
249
<layout type="log4net.Layout.PatternLayout">
@@ -31,8 +16,4 @@
3116
<appender-ref ref="exceptionless"/>
3217
</root>
3318
</log4net>
34-
35-
<startup>
36-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
37-
</startup>
3819
</configuration>

src/Samples/Exceptionless.SampleConsole/Program.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
22
using System.Diagnostics;
33
using System.IO;
4+
using System.Reflection;
45
using System.Threading;
56
using System.Threading.Tasks;
7+
using Exceptionless.Configuration;
68
using Exceptionless.DateTimeExtensions;
79
using Exceptionless.Dependency;
810
using Exceptionless.Extensions;
@@ -17,6 +19,10 @@
1719
using NLog;
1820
using LogLevel = Exceptionless.Logging.LogLevel;
1921

22+
// example of setting an attribute value in config.
23+
[assembly: Exceptionless("LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw", ServerUrl = "http://localhost:50000")]
24+
[assembly: ExceptionlessSetting("EnableWelcomeMessage", "True")]
25+
2026
namespace Exceptionless.SampleConsole {
2127
public class Program {
2228

@@ -39,21 +45,22 @@ public static void Main(string[] args) {
3945
StartDisplayingLogMessages();
4046

4147
ExceptionlessClient.Default.Configuration.UpdateSettingsWhenIdleInterval = TimeSpan.FromSeconds(15);
42-
ExceptionlessClient.Default.Configuration.UseTraceLogEntriesPlugin();
4348
ExceptionlessClient.Default.Configuration.AddPlugin<SystemUptimePlugin>();
4449
ExceptionlessClient.Default.Configuration.UseFolderStorage("store");
4550
ExceptionlessClient.Default.Configuration.UseLogger(_log);
46-
//ExceptionlessClient.Default.Configuration.SubmissionBatchSize = 1;
4751
ExceptionlessClient.Default.Startup();
4852

49-
// test NLog
53+
if (ExceptionlessClient.Default.Configuration.Settings.GetBoolean("EnableWelcomeMessage", false))
54+
Console.WriteLine($"Hello {Environment.MachineName}!");
55+
56+
// Test NLog
5057
GlobalDiagnosticsContext.Set("GlobalProp", "GlobalValue");
5158
//Log.Info().Message("Hi").Tag("Tag1", "Tag2").Property("LocalProp", "LocalValue").MarkUnhandled("SomeMethod").ContextProperty("Blah", new Event()).Write();
5259

5360
//ExceptionlessClient.Default.SubmitLog(typeof(Program).Name, "Trace Message", LogLevel.Trace);
5461

5562
#if NET45
56-
// test log4net
63+
// Test log4net
5764
XmlConfigurator.Configure();
5865
GlobalContext.Properties["GlobalProp"] = "GlobalValue";
5966
ThreadContext.Properties["LocalProp"] = "LocalValue";
@@ -63,7 +70,6 @@ public static void Main(string[] args) {
6370
var tokenSource = new CancellationTokenSource();
6471
CancellationToken token = tokenSource.Token;
6572

66-
ExceptionlessClient.Default.Configuration.AddPlugin(ctx => ctx.Event.Data[RandomData.GetWord()] = RandomData.GetWord());
6773
ExceptionlessClient.Default.Configuration.AddPlugin(ctx => ctx.Event.Data[RandomData.GetWord()] = RandomData.GetWord());
6874
ExceptionlessClient.Default.Configuration.AddPlugin(ctx => {
6975
// use server settings to see if we should include this data
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
using System;
22
using System.Reflection;
33
using System.Runtime.InteropServices;
4-
//using Exceptionless.Configuration;
54

65
[assembly: AssemblyTitle("SampleConsole")]
76
[assembly: AssemblyCulture("")]
87
[assembly: ComVisible(false)]
9-
[assembly: Guid("2a45b7bb-82b6-4055-8c8e-1a3c81afb4f1")]
10-
11-
12-
// example of setting an attribute value in config.
13-
//[assembly: ExceptionlessSetting("AttributeSettings", "AttributeValue")]
8+
[assembly: Guid("2a45b7bb-82b6-4055-8c8e-1a3c81afb4f1")]

src/Samples/Exceptionless.SampleWeb/Exceptionless.SampleWeb.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<DependentUpon>Global.asax</DependentUpon>
109109
</Compile>
110110
<Compile Include="Properties\AssemblyInfo.cs" />
111+
<Compile Include="Submission\InMemorySubmissionClient.cs" />
111112
<Compile Include="TestService.svc.cs">
112113
<DependentUpon>TestService.svc</DependentUpon>
113114
</Compile>

src/Samples/Exceptionless.SampleConsole/Submission/InMemorySubmissionClient.cs renamed to src/Samples/Exceptionless.SampleWeb/Submission/InMemorySubmissionClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Exceptionless.Models.Data;
55
using Exceptionless.Submission;
66

7-
namespace Exceptionless.SampleConsole {
7+
namespace Exceptionless.SampleWeb {
88
public class InMemorySubmissionClient : ISubmissionClient {
99
private readonly Dictionary<string, object> _eventContainer = new Dictionary<string, object>();
1010
private readonly Dictionary<string, object> _userDescriptionContainer = new Dictionary<string, object>();

src/Samples/Exceptionless.SampleWeb/Web.config

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
<configSections>
44
<section name="exceptionless" type="Exceptionless.ExceptionlessSection, Exceptionless" requirePermission="false"/>
55
</configSections>
6-
<exceptionless apiKey="LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw" serverUrl="http://localhost:50000">
6+
<exceptionless apiKey="LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw" serverUrl="http://localhost:50000" tags="Tag1,Tag2">
77
<settings>
88
<add name="TraceLogLimit" value="30"/>
9+
<add name="IncludeConditionalData" value="true"/>
910
</settings>
11+
<data>
12+
<add name="SimpleValueFromConfig" value="Exceptionless"/>
13+
<add name="JsonDataFromConfig" value="{ &quot;Property1&quot;: &quot;Exceptionless&quot;, &quot;Property2&quot;: 10, &quot;Property3&quot;: true }"/>
14+
</data>
15+
<!--<registrations>
16+
<registration service="ISubmissionClient" type="Exceptionless.SampleWeb.InMemorySubmissionClient, Exceptionless.SampleWeb" />
17+
</registrations>-->
1018
</exceptionless>
1119
<appSettings/>
1220
<connectionStrings/>

0 commit comments

Comments
 (0)