Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging implementation update #871

Merged
merged 53 commits into from
Nov 1, 2023
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
204d8f8
Logging implementation update
sjuarezgx Sep 3, 2023
495fbc6
Exclude new logging API for Net FW, use the previous one.
sjuarezgx Sep 6, 2023
c67e6f7
Enable MsExtensions Logging only for .NET.
claudiamurialdo Sep 6, 2023
53027ae
Add missing file.
claudiamurialdo Sep 6, 2023
014d979
Rename test.
claudiamurialdo Sep 6, 2023
1e13260
Make GXLoggerMsExtensions and GXLoggerLog4Net internals as they are n…
claudiamurialdo Sep 6, 2023
3c14450
Remove wrong .cs in .sln
claudiamurialdo Sep 11, 2023
9e6c779
Implementation for NET to use Microsoft.Extensions.Logging API.
sjuarezgx Sep 24, 2023
c2c9445
Merge branch 'LoggingAPIImpl_Update' of https://github.com/genexuslab…
sjuarezgx Sep 25, 2023
8ff31b0
Merge branch 'master' into LoggingAPIImpl_Update
sjuarezgx Sep 25, 2023
ac5bbca
fix merge error
sjuarezgx Sep 25, 2023
19c9467
Fix in previous merge which not included changes already released
sjuarezgx Sep 25, 2023
585b983
Fix unit test.
sjuarezgx Sep 26, 2023
78414ae
Fix case not working for reading appsettings.<env>.json
sjuarezgx Sep 26, 2023
8c9186b
Minor change to re-run tests
sjuarezgx Sep 26, 2023
9673496
Fix test failure.
sjuarezgx Sep 27, 2023
dceb034
Fix TestCouldNotLoadSystemDiagnosticsDiagnosticSource7_0_0_0 test.
claudiamurialdo Sep 27, 2023
acde512
Define environment variables exclusively for the current process.
claudiamurialdo Sep 27, 2023
72f2db5
Set environment variables earlier to enable the Startup program to re…
claudiamurialdo Sep 27, 2023
93bbf81
Support to use defaultAzureCredentials again.
sjuarezgx Sep 27, 2023
b0c5179
Do not distribute always ApplicationInsights dependencies.
sjuarezgx Sep 28, 2023
a0fa045
dummy commit
sjuarezgx Oct 17, 2023
b363c15
Merge branch 'master' into LoggingAPIImpl_Update
sjuarezgx Oct 17, 2023
f5abb1c
use new loggger factory
sjuarezgx Oct 18, 2023
3c9cec2
update to new new logger factory
sjuarezgx Oct 18, 2023
abab49c
Simplify class names.
claudiamurialdo Oct 18, 2023
aa055f4
Cyclic dependendy fixed using App insights logging
sjuarezgx Oct 19, 2023
a7e7f33
Use AzureMonitorLogExporter when Opentelemetry for Azure App Insights…
sjuarezgx Oct 22, 2023
d36ec7c
Do not need to set Logoutput to App Insights if Azure Opentelemetry i…
sjuarezgx Oct 22, 2023
2401c8b
skip tests to try to build the branch
sjuarezgx Oct 23, 2023
0393f33
Remove unnecessary public visibility from the GetLogger method.
claudiamurialdo Oct 23, 2023
5f0f2a5
Try to fix tests
sjuarezgx Oct 24, 2023
30e1024
Threads were locked when attempting to acquire a logger using GetLogg…
claudiamurialdo Oct 24, 2023
72cad9e
Eliminate the returns from config.get to allow the final trace lines …
claudiamurialdo Oct 24, 2023
69496bd
Set GXLoggerFactory._instance to a private access modifier.
claudiamurialdo Oct 24, 2023
bedb28e
Remove log initialization inside lock.
claudiamurialdo Oct 24, 2023
0732ffd
Ensure that services are loaded in the configuration, as logging depe…
claudiamurialdo Oct 24, 2023
42639bb
Added some constants.
claudiamurialdo Oct 24, 2023
550fb97
Restore AttackMitigation tests.
claudiamurialdo Oct 24, 2023
04a178a
Remove the dependency between gxservices.config and the logging confi…
claudiamurialdo Oct 24, 2023
b477aa0
Update libraries for some proyects that include Azure.Core as transit…
sjuarezgx Oct 25, 2023
3a1ad38
Add reference to Azure.Core 1.35 to projects.
sjuarezgx Oct 25, 2023
7428fcc
Extended the AssemblyResolve method to dynamically load assemblies ba…
claudiamurialdo Oct 25, 2023
5db72ec
Merge branch 'LoggingAPIImpl_Update' of https://github.com/genexuslab…
claudiamurialdo Oct 25, 2023
2dbf3fe
make exception message more clear when App Insights env variable is m…
sjuarezgx Oct 26, 2023
88c694e
Merge branch 'LoggingAPIImpl_Update' of https://github.com/genexuslab…
sjuarezgx Oct 26, 2023
57bb4d7
First must evaluate if it's Otel Azure Monitor. Besides, there was a …
sjuarezgx Oct 29, 2023
066dbab
dummy commit
sjuarezgx Oct 30, 2023
4bcf3b5
Set minimum log level by reading env var.
sjuarezgx Nov 1, 2023
a33caaa
Merge branch 'master' into LoggingAPIImpl_Update
sjuarezgx Nov 1, 2023
02a050e
The reference to the log4net package is no longer necessary for proje…
claudiamurialdo Nov 1, 2023
1a9a507
Added thread ID to the context properties of log4net as a workaround …
claudiamurialdo Nov 1, 2023
ce66577
Fix build error.
claudiamurialdo Nov 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions dotnet/DotNetStandardClasses.sln
Original file line number Diff line number Diff line change
@@ -104,6 +104,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXAzureStorage", "src\dotnetcore\Providers\Storage\GXAzureStorage\GXAzureStorage.csproj", "{BF72FAF5-3A7C-41B6-A27F-9BE049290356}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}"
ProjectSection(SolutionItems) = preProject
claudiamurialdo marked this conversation as resolved.
Show resolved Hide resolved
src\dotnetcore\GxNetCoreStartup\Startup.cs = src\dotnetcore\GxNetCoreStartup\Startup.cs
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GxEncryptCMD", "src\dotnetframework\GxEncryptCMD\GxEncryptCMD.csproj", "{E2CC404A-3AE4-4CE9-84DC-0EA6078F69E3}"
EndProject
@@ -249,6 +252,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXAzureEventGrid", "src\dot
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCoreAttackMitigationTest", "test\DotNetCoreAttackMitigationTest\DotNetCoreAttackMitigationTest.csproj", "{2D615969-53E2-4B77-9A9A-75C33865CF76}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gxlogging", "gxlogging", "{AA04A8A9-3CBD-431D-9711-C4D481E4A1E5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneXus.Log.Azure.AzureAppInsights", "src\dotnetcore\Providers\Logging\GeneXus.Log.Azure.AzureAppInsights\GeneXus.Log.Azure.AzureAppInsights.csproj", "{6B28F942-D355-44A2-9C5D-92AF2D256A0D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -603,6 +610,10 @@ Global
{2D615969-53E2-4B77-9A9A-75C33865CF76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D615969-53E2-4B77-9A9A-75C33865CF76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D615969-53E2-4B77-9A9A-75C33865CF76}.Release|Any CPU.Build.0 = Release|Any CPU
{6B28F942-D355-44A2-9C5D-92AF2D256A0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B28F942-D355-44A2-9C5D-92AF2D256A0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B28F942-D355-44A2-9C5D-92AF2D256A0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B28F942-D355-44A2-9C5D-92AF2D256A0D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -722,6 +733,8 @@ Global
{5BBC75F0-E51A-4EBD-A628-92498D319B1D} = {4C43F2DA-59E5-46F5-B691-195449498555}
{7250CDB1-95C4-4822-B01B-3CBD73324CC9} = {30159B0F-BE61-4DB7-AC02-02851426BE4B}
{2D615969-53E2-4B77-9A9A-75C33865CF76} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
{AA04A8A9-3CBD-431D-9711-C4D481E4A1E5} = {2261B65E-3757-4E5B-9DCD-EAE8D1E236A3}
{6B28F942-D355-44A2-9C5D-92AF2D256A0D} = {AA04A8A9-3CBD-431D-9711-C4D481E4A1E5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E18684C9-7D76-45CD-BF24-E3944B7F174C}
2 changes: 2 additions & 0 deletions dotnet/src/dotnetcore/GxClasses.Web/GxClasses.Web.csproj
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@

<ItemGroup>
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
2 changes: 2 additions & 0 deletions dotnet/src/dotnetcore/GxClasses/GxClasses.csproj
Original file line number Diff line number Diff line change
@@ -157,6 +157,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="MySqlConnector" Version="2.2.3" />
<PackageReference Include="NetTopologySuite" Version="2.0.0" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using GeneXus.Application;
using GxClasses.Helpers;
using Microsoft.Extensions.Logging;

namespace GeneXus.Services.Log
{
public interface IGXLogProvider : ILoggerFactory
{
ILoggerFactory GetLoggerFactory();
}

public static class GXLogService
claudiamurialdo marked this conversation as resolved.
Show resolved Hide resolved
{
private static string LOG_SERVICE = "Log";

public static ILoggerFactory GetLogFactory()
{
IGXLogProvider gxLogProvider = null;
GXService providerService = GXServices.Instance?.Get(LOG_SERVICE);

if (providerService != null)
{
try
{
#if !NETCORE
Type type = Type.GetType(providerService.ClassName, true, true);
#else
Type type = AssemblyLoader.GetType(providerService.ClassName);
#endif
gxLogProvider = (IGXLogProvider)Activator.CreateInstance(type, new object[] { providerService });
return gxLogProvider.GetLoggerFactory();
}
catch (Exception e)
{
throw e;
}
}
else
{
string log4net_config = GxContext.IsHttpContext ? "log.config" : "log.console.config";
Log4NetProvider log4NetProvider = new Log4NetProvider(log4net_config);
return LoggerFactory.Create(builder => builder.AddProvider(log4NetProvider));
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using GeneXus.Services;
using GeneXus.Services.Log;
using Microsoft.Extensions.Logging;

namespace GeneXus.Log.Azure
{
public class AzureAppInsightsLogProvider : IGXLogProvider
{
private static string APPLICATIONINSIGHTS_CONNECTION_STRING = "APPLICATIONINSIGHTS_CONNECTION_STRING";

public static ILoggerFactory loggerFactory;

public AzureAppInsightsLogProvider(GXService s) { }
public ILoggerFactory GetLoggerFactory()
{
string appInsightsConnection = Environment.GetEnvironmentVariable(APPLICATIONINSIGHTS_CONNECTION_STRING);
if (appInsightsConnection != null) {
loggerFactory = LoggerFactory.Create(builder => builder.AddApplicationInsights(

configureTelemetryConfiguration: (config) =>
config.ConnectionString = appInsightsConnection,
configureApplicationInsightsLoggerOptions: (options) => { }
)
);

}
else
{
throw new ArgumentNullException("APPLICATIONINSIGHTS_CONNECTION_STRING","Application Insight Log could not be initialized due to missing APPLICATIONINSIGHTS_CONNECTION_STRING environment variable.");
}
return loggerFactory;
}

public void AddProvider(ILoggerProvider provider)
claudiamurialdo marked this conversation as resolved.
Show resolved Hide resolved
{
loggerFactory.AddProvider(provider);
}

public void Dispose()
claudiamurialdo marked this conversation as resolved.
Show resolved Hide resolved
{
loggerFactory.Dispose();
}

public ILogger CreateLogger(string name)
claudiamurialdo marked this conversation as resolved.
Show resolved Hide resolved
{
return loggerFactory.CreateLogger(name);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<DefineConstants>NETCORE;</DefineConstants>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SignAssembly>false</SignAssembly>
<AssemblyName>GeneXus.Log.Azure.AzureAppInsights</AssemblyName>
<PackageTags>Azure Application Insights Log GeneXus</PackageTags>
<PackageId>GeneXus.Log.Azure.AzureAppInsights</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.21.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\GxClasses\GxClasses.csproj" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions dotnet/src/dotnetframework/GxClasses/GxClasses.csproj
Original file line number Diff line number Diff line change
@@ -8,8 +8,13 @@
<PackageTags>Data Access</PackageTags>
<PackageId>GeneXus.Classes</PackageId>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\dotnetcore\GxClasses\Services\LogService\GXLogService.cs" Link="Services\GXLogService.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="GeneXus.NodaTime" Version="2.4.19.1" />
<PackageReference Include="ManagedFusion.Rewriter" Version="3.7.0" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.9" />
318 changes: 302 additions & 16 deletions dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

Large diffs are not rendered by default.