Skip to content

Commit 1411f4a

Browse files
committed
Semantic Logging Application Block Added
1 parent f80f6ad commit 1411f4a

File tree

78 files changed

+8797
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+8797
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ The design of application blocks encapsulates the Microsoft recommended and prov
3030
* [Transient Fault Handling Application Block - Caching Integration](https://www.nuget.org/packages/EnterpriseLibrary.TransientFaultHandling.Caching.NetCore/)
3131
* [Transient Fault Handling Application Block - Windows Azure SQL Database Integration](https://www.nuget.org/packages/EnterpriseLibrary.TransientFaultHandling.Data.NetCore/)
3232
* [Transient Fault Handling Application Block - Declarative Configuration Support](https://www.nuget.org/packages/EnterpriseLibrary.TransientFaultHandling.Configuration.NetCore/)
33+
* [Semantic Logging Application Block](https://www.nuget.org/packages/EnterpriseLibrary.SemanticLogging.NetCore/)
34+
* [Semantic Logging Application Block - SQL Server Sink](https://www.nuget.org/packages/EnterpriseLibrary.SemanticLogging.Database.NetCore/)
35+
* [Semantic Logging Application Block - EventSource Analyzer](https://www.nuget.org/packages/EnterpriseLibrary.SemanticLogging.EventSourceAnalyzer.NetCore/)
36+
* [Semantic Logging Application Block - Text File Sinks](https://www.nuget.org/packages/EnterpriseLibrary.SemanticLogging.TextFile.NetCore/)
3337
* [Cryptography Application Block (Enterprise Library 5.0)](https://www.nuget.org/packages/EnterpriseLibrary.Security.Cryptography/)
3438
* [Caching Application Block (Enterprise Library 5.0)](https://www.nuget.org/packages/EnterpriseLibrary.Caching.NetCore/)
3539
* [Caching Application Block Cryptography Provider (Enterprise Library 5.0)](https://www.nuget.org/packages/EnterpriseLibrary.Caching.Cryptography/)

Source/EnterpriseLibrary.sln

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Caching.Database", "Caching
4545
EndProject
4646
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Transient Fault Handling Application Block", "Transient Fault Handling Application Block", "{66B030BD-13B8-45D6-9AC8-35EAEC7165F4}"
4747
EndProject
48-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransientFaultHandling", "Transient Fault Handling Application Block\TransientFaultHandling\TransientFaultHandling.csproj", "{19BEFF33-A451-4319-AA64-8EB3B8EF5641}"
48+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransientFaultHandling", "Transient Fault Handling Application Block\TransientFaultHandling\TransientFaultHandling.csproj", "{19BEFF33-A451-4319-AA64-8EB3B8EF5641}"
4949
EndProject
50-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransientFaultHandling.Caching", "Transient Fault Handling Application Block\TransientFaultHandling.Caching\TransientFaultHandling.Caching.csproj", "{ACFAE28D-163B-448C-ABC4-BA57A02556F9}"
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransientFaultHandling.Caching", "Transient Fault Handling Application Block\TransientFaultHandling.Caching\TransientFaultHandling.Caching.csproj", "{ACFAE28D-163B-448C-ABC4-BA57A02556F9}"
5151
EndProject
52-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransientFaultHandling.Data", "Transient Fault Handling Application Block\TransientFaultHandling.Data\TransientFaultHandling.Data.csproj", "{B92C5C34-8685-4743-89E9-27FD034B7AC2}"
52+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransientFaultHandling.Data", "Transient Fault Handling Application Block\TransientFaultHandling.Data\TransientFaultHandling.Data.csproj", "{B92C5C34-8685-4743-89E9-27FD034B7AC2}"
5353
EndProject
5454
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransientFaultHandling.Configuration", "Transient Fault Handling Application Block\TransientFaultHandling.Configuration\TransientFaultHandling.Configuration.csproj", "{09242E89-03A0-42FB-9D66-D9C7DE290D3D}"
5555
EndProject
56+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Semantic Logging Application Block", "Semantic Logging Application Block", "{5AE6BB07-BDFF-437C-9D97-BC2C0E990534}"
57+
EndProject
58+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SemanticLogging", "Semantic Logging Application Block\SemanticLogging\SemanticLogging.csproj", "{36C31FE5-4F5A-4A92-AFDD-C78722592C75}"
59+
EndProject
60+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SemanticLogging.Database", "Semantic Logging Application Block\SemanticLogging.Database\SemanticLogging.Database.csproj", "{DA33AEAA-3559-4775-B948-1FE679E702BC}"
61+
EndProject
62+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SemanticLogging.EventSourceAnalyzer", "Semantic Logging Application Block\SemanticLogging.EventSourceAnalyzer\SemanticLogging.EventSourceAnalyzer.csproj", "{9B58C5CE-CC96-4E25-BBE8-13DB28540A88}"
63+
EndProject
64+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SemanticLogging.TextFile", "Semantic Logging Application Block\SemanticLogging.TextFile\SemanticLogging.TextFile.csproj", "{53235734-E63D-4D76-8830-F322A3E8B0D3}"
65+
EndProject
5666
Global
5767
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5868
Debug|Any CPU = Debug|Any CPU
@@ -123,6 +133,22 @@ Global
123133
{09242E89-03A0-42FB-9D66-D9C7DE290D3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
124134
{09242E89-03A0-42FB-9D66-D9C7DE290D3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
125135
{09242E89-03A0-42FB-9D66-D9C7DE290D3D}.Release|Any CPU.Build.0 = Release|Any CPU
136+
{36C31FE5-4F5A-4A92-AFDD-C78722592C75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137+
{36C31FE5-4F5A-4A92-AFDD-C78722592C75}.Debug|Any CPU.Build.0 = Debug|Any CPU
138+
{36C31FE5-4F5A-4A92-AFDD-C78722592C75}.Release|Any CPU.ActiveCfg = Release|Any CPU
139+
{36C31FE5-4F5A-4A92-AFDD-C78722592C75}.Release|Any CPU.Build.0 = Release|Any CPU
140+
{DA33AEAA-3559-4775-B948-1FE679E702BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
141+
{DA33AEAA-3559-4775-B948-1FE679E702BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
142+
{DA33AEAA-3559-4775-B948-1FE679E702BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
143+
{DA33AEAA-3559-4775-B948-1FE679E702BC}.Release|Any CPU.Build.0 = Release|Any CPU
144+
{9B58C5CE-CC96-4E25-BBE8-13DB28540A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
145+
{9B58C5CE-CC96-4E25-BBE8-13DB28540A88}.Debug|Any CPU.Build.0 = Debug|Any CPU
146+
{9B58C5CE-CC96-4E25-BBE8-13DB28540A88}.Release|Any CPU.ActiveCfg = Release|Any CPU
147+
{9B58C5CE-CC96-4E25-BBE8-13DB28540A88}.Release|Any CPU.Build.0 = Release|Any CPU
148+
{53235734-E63D-4D76-8830-F322A3E8B0D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
149+
{53235734-E63D-4D76-8830-F322A3E8B0D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
150+
{53235734-E63D-4D76-8830-F322A3E8B0D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
151+
{53235734-E63D-4D76-8830-F322A3E8B0D3}.Release|Any CPU.Build.0 = Release|Any CPU
126152
EndGlobalSection
127153
GlobalSection(SolutionProperties) = preSolution
128154
HideSolutionNode = FALSE
@@ -144,6 +170,10 @@ Global
144170
{ACFAE28D-163B-448C-ABC4-BA57A02556F9} = {66B030BD-13B8-45D6-9AC8-35EAEC7165F4}
145171
{B92C5C34-8685-4743-89E9-27FD034B7AC2} = {66B030BD-13B8-45D6-9AC8-35EAEC7165F4}
146172
{09242E89-03A0-42FB-9D66-D9C7DE290D3D} = {66B030BD-13B8-45D6-9AC8-35EAEC7165F4}
173+
{36C31FE5-4F5A-4A92-AFDD-C78722592C75} = {5AE6BB07-BDFF-437C-9D97-BC2C0E990534}
174+
{DA33AEAA-3559-4775-B948-1FE679E702BC} = {5AE6BB07-BDFF-437C-9D97-BC2C0E990534}
175+
{9B58C5CE-CC96-4E25-BBE8-13DB28540A88} = {5AE6BB07-BDFF-437C-9D97-BC2C0E990534}
176+
{53235734-E63D-4D76-8830-F322A3E8B0D3} = {5AE6BB07-BDFF-437C-9D97-BC2C0E990534}
147177
EndGlobalSection
148178
GlobalSection(ExtensibilityGlobals) = postSolution
149179
SolutionGuid = {D33D36F1-68F5-4C14-BBC4-32E07BACF8AE}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
2+
3+
using System;
4+
using System.Xml.Linq;
5+
using Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Observable;
6+
using Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Utility;
7+
8+
namespace Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Configuration
9+
{
10+
internal class SqlDatabaseSinkElement : ISinkElement
11+
{
12+
private readonly XName sinkName = XName.Get("sqlDatabaseSink", Constants.Namespace);
13+
14+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Validated with Guard class")]
15+
public bool CanCreateSink(XElement element)
16+
{
17+
Guard.ArgumentNotNull(element, "element");
18+
19+
return element.Name == this.sinkName;
20+
}
21+
22+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Validated with Guard class")]
23+
public IObserver<EventEntry> CreateSink(XElement element)
24+
{
25+
Guard.ArgumentNotNull(element, "element");
26+
27+
var subject = new EventEntrySubject();
28+
subject.LogToSqlDatabase(
29+
(string)element.Attribute("instanceName"),
30+
(string)element.Attribute("connectionString"),
31+
(string)element.Attribute("tableName") ?? SqlDatabaseLog.DefaultTableName,
32+
(string)element.Attribute("storedProcedureName") ?? SqlDatabaseLog.DefaultStoredProcedureName,
33+
element.Attribute("bufferingIntervalInSeconds").ToTimeSpan(),
34+
(int?)element.Attribute("bufferingCount") ?? Buffering.DefaultBufferingCount,
35+
element.Attribute("bufferingFlushAllTimeoutInSeconds").ToTimeSpan() ?? Constants.DefaultBufferingFlushAllTimeout,
36+
(int?)element.Attribute("maxBufferSize") ?? Buffering.DefaultMaxBufferSize);
37+
38+
return subject;
39+
}
40+
}
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
2+
3+
// This file is used by Code Analysis to maintain SuppressMessage
4+
// attributes that are applied to this project.
5+
// Project-level suppressions either have no target or are given
6+
// a specific target and scoped to a namespace, type, member, etc.
7+
//
8+
// To add a suppression to this file, right-click the message in the
9+
// Code Analysis results, point to "Suppress Message", and click
10+
// "In Suppression File".
11+
// You do not need to add suppressions to this file manually.
12+
13+
// suppressions for "few types"
14+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Practices.EnterpriseLibrary.SemanticLogging", Justification = "As designed")]
15+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks", Justification = "As designed")]
16+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.Database", Justification = "As designed")]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* NOT SUPPORTED IN SQL AZURE: Both the CREATE DATABASE and DROP DATABASE statements must be in a seperate file.
2+
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'Logging')
3+
DROP DATABASE [Logging]
4+
GO
5+
*/
6+
7+
CREATE DATABASE [Logging]
8+
/* NOT SUPPORTED IN SQL AZURE
9+
COLLATE SQL_Latin1_General_CP1_CI_AS
10+
*/
11+
GO
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
SET ANSI_NULLS ON
2+
GO
3+
SET QUOTED_IDENTIFIER ON
4+
GO
5+
6+
CREATE TYPE TracesType AS TABLE
7+
(
8+
[InstanceName] [nvarchar](1000),
9+
[ProviderId] [uniqueidentifier],
10+
[ProviderName] [nvarchar](500),
11+
[EventId] [int],
12+
[EventKeywords] [bigint],
13+
[Level] [int],
14+
[Opcode] [int],
15+
[Task] [int],
16+
[Timestamp] [datetimeoffset](7),
17+
[Version] [int],
18+
[FormattedMessage] [nvarchar](4000),
19+
[Payload] [nvarchar](4000),
20+
[ActivityId] [uniqueidentifier],
21+
[RelatedActivityId] [uniqueidentifier],
22+
[ProcessId] [int],
23+
[ThreadId] [int]
24+
);
25+
26+
GO
27+
28+
-- The name of this stored procedure should match to the storedProcedureName parameter when creating the sink
29+
CREATE PROCEDURE [dbo].[WriteTraces]
30+
(
31+
@InsertTraces TracesType READONLY
32+
)
33+
AS
34+
BEGIN
35+
INSERT INTO [Traces] (
36+
[InstanceName],
37+
[ProviderId],
38+
[ProviderName],
39+
[EventId],
40+
[EventKeywords],
41+
[Level],
42+
[Opcode],
43+
[Task],
44+
[Timestamp],
45+
[Version],
46+
[FormattedMessage],
47+
[Payload],
48+
[ActivityId],
49+
[RelatedActivityId],
50+
[ProcessId],
51+
[ThreadId]
52+
)
53+
SELECT * FROM @InsertTraces;
54+
END
55+
56+
GO
57+
58+
-- The name of this table should match to the tableName parameter when creating the sink
59+
CREATE TABLE [dbo].[Traces](
60+
[id] [bigint] IDENTITY(1,1) NOT NULL,
61+
[InstanceName] [nvarchar](1000) NOT NULL,
62+
[ProviderId] [uniqueidentifier] NOT NULL,
63+
[ProviderName] [nvarchar](500) NOT NULL,
64+
[EventId] [int] NOT NULL,
65+
[EventKeywords] [bigint] NOT NULL,
66+
[Level] [int] NOT NULL,
67+
[Opcode] [int] NOT NULL,
68+
[Task] [int] NOT NULL,
69+
[Timestamp] [datetimeoffset](7) NOT NULL,
70+
[Version] [int] NOT NULL,
71+
[FormattedMessage] [nvarchar](4000) NULL,
72+
[Payload] [nvarchar](4000) NULL,
73+
[ActivityId] [uniqueidentifier],
74+
[RelatedActivityId] [uniqueidentifier],
75+
[ProcessId] [int],
76+
[ThreadId] [int],
77+
CONSTRAINT [PK_Traces] PRIMARY KEY CLUSTERED
78+
(
79+
[id] ASC
80+
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF)
81+
)
82+
83+
GO
84+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sqlcmd -S (localdb)\v11.0 -E -i CreateSemanticLoggingDatabase.sql
2+
sqlcmd -S (localdb)\v11.0 -E -i CreateSemanticLoggingDatabaseObjects.sql -d Logging
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<AssemblyName>Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Database</AssemblyName>
6+
<RootNamespace>Microsoft.Practices.EnterpriseLibrary.SemanticLogging</RootNamespace>
7+
8+
<PackageId>EnterpriseLibrary.SemanticLogging.Database.NetCore</PackageId>
9+
<Title>Semantic Logging Application Block - SQL Server Sink for .Net Core</Title>
10+
<PackageVersion>2.0.1406.1</PackageVersion>
11+
<Authors>Mohammad Chavoshi</Authors>
12+
<Description>The Semantic Logging Application Block provides a set of destinations to persist events published by a subclass of EventSource, This add-on packages adds support to persisting log entries in SQL Server and Azure SQL Database. This library contains a class library that targets .Net Core 2.0.</Description>
13+
<PackageTags>entlib entlib6 slab enterprise library semantic logging EventSource event listener structured strongly-typed block sink SQL database table futures OSS NetCore</PackageTags>
14+
<PackageIconUrl>http://nuget.org/Media/Default/Packages/Unity/2.0/entlib_new_icon_100x100.png</PackageIconUrl>
15+
<PackageProjectUrl>https://github.com/Chavoshi/EnterpriseLibrary.NetCore</PackageProjectUrl>
16+
<PackageLicenseUrl>http://opensource.org/licenses/Apache-2.0</PackageLicenseUrl>
17+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
18+
<Version>2.0.1406.1</Version>
19+
<AssemblyVersion>2.0.0.0</AssemblyVersion>
20+
<FileVersion>2.0.1406.1</FileVersion>
21+
</PropertyGroup>
22+
23+
<ItemGroup>
24+
<PackageReference Include="System.Data.SqlClient" Version="4.4.0-preview2-25405-01" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<ProjectReference Include="..\..\Transient Fault Handling Application Block\TransientFaultHandling.Data\TransientFaultHandling.Data.csproj" />
29+
<ProjectReference Include="..\SemanticLogging\SemanticLogging.csproj" />
30+
</ItemGroup>
31+
32+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
33+
<Exec Command="xcopy &quot;$(OutDir)*.*&quot; &quot;$(SolutionDir)..\Build\$(ConfigurationName)\&quot; /s /i /y /d" />
34+
</Target>
35+
36+
</Project>

0 commit comments

Comments
 (0)