This is an automated email from the ASF dual-hosted git repository.

freeandnil pushed a commit to branch Feature/225-XmlLayoutSchemaLog4JTest-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git

commit 634e7bc2184f358b5c84fe678a2fdda06ad122d2
Author: Jan Friedrich <[email protected]>
AuthorDate: Tue Feb 4 11:02:08 2025 +0100

    Test for #225
---
 .../log4net-611-main/log4net-611-main.csproj       |  2 +-
 .../Layout/XmlLayoutSchemaLog4jTest.cs             | 67 ++++++++++++++++++++++
 src/log4net.Tests/log4net.Tests.csproj             |  4 +-
 src/log4net/log4net.csproj                         |  4 +-
 4 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/src/integration-testing/log4net-611-main/log4net-611-main.csproj 
b/src/integration-testing/log4net-611-main/log4net-611-main.csproj
index a3474a3c..4ffaabf2 100644
--- a/src/integration-testing/log4net-611-main/log4net-611-main.csproj
+++ b/src/integration-testing/log4net-611-main/log4net-611-main.csproj
@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFrameworks>net462;net6.0</TargetFrameworks>
+    <TargetFrameworks>net471;net6.0</TargetFrameworks>
     <RootNamespace>log4net_611_main</RootNamespace>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
diff --git a/src/log4net.Tests/Layout/XmlLayoutSchemaLog4jTest.cs 
b/src/log4net.Tests/Layout/XmlLayoutSchemaLog4jTest.cs
new file mode 100644
index 00000000..4bf054c8
--- /dev/null
+++ b/src/log4net.Tests/Layout/XmlLayoutSchemaLog4jTest.cs
@@ -0,0 +1,67 @@
+#region Apache License
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more 
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership. 
+// The ASF licenses this file to you under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with 
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#endregion
+
+using System;
+using System.IO;
+using System.Xml;
+
+using log4net.Config;
+using log4net.Core;
+using log4net.Layout;
+using log4net.Repository;
+using log4net.Tests.Appender;
+using log4net.Util;
+
+using NUnit.Framework;
+using System.Globalization;
+
+namespace log4net.Tests.Layout
+{
+  [TestFixture]
+  public class XmlLayoutSchemaLog4jTest
+  {
+    [Test]
+    public void LogExceptionTest()
+    {
+      XmlLayoutSchemaLog4j layout = new();
+      StringAppender stringAppender = new() { Layout = layout };
+
+      ILoggerRepository rep = 
LogManager.CreateRepository(Guid.NewGuid().ToString());
+      BasicConfigurator.Configure(rep, stringAppender);
+      ILog log1 = LogManager.GetLogger(rep.Name, "TestLogger");
+      Bar(42);
+
+      // really only asserts there is no exception
+      XmlDocument loggedDoc = new();
+      loggedDoc.LoadXml(stringAppender.GetString());
+
+      void Bar(int foo)
+      {
+        try
+        {
+          throw new TimeoutException();
+        }
+        catch (Exception ex)
+        {
+          log1.Error(string.Format("Error {0}", foo), ex);
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/log4net.Tests/log4net.Tests.csproj 
b/src/log4net.Tests/log4net.Tests.csproj
index 6e520839..003e16e9 100644
--- a/src/log4net.Tests/log4net.Tests.csproj
+++ b/src/log4net.Tests/log4net.Tests.csproj
@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <IsTestProject>true</IsTestProject>
-    <TargetFrameworks>net462;net8.0</TargetFrameworks>
+    <TargetFrameworks>net471;net8.0</TargetFrameworks>
     <NoWarn>NETSDK1138;CS1701</NoWarn>
     <OutputType>Library</OutputType>
     <OutputPath>bin\$(Configuration)</OutputPath>
@@ -26,7 +26,7 @@
     <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
     <PackageReference Include="Quackers.TestLogger" Version="1.0.24" />
   </ItemGroup>
-  <ItemGroup Condition="'$(TargetFramework)'=='net462'">
+  <ItemGroup Condition="'$(TargetFramework)'=='net471'">
     <Reference Include="System.Configuration" />
     <Reference Include="System.Runtime.Remoting" />
   </ItemGroup>
diff --git a/src/log4net/log4net.csproj b/src/log4net/log4net.csproj
index 5006a60b..e6b649ef 100644
--- a/src/log4net/log4net.csproj
+++ b/src/log4net/log4net.csproj
@@ -31,7 +31,7 @@
     <RepositoryUrl>https://github.com/apache/logging-log4net</RepositoryUrl>
     <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
     <Platforms>AnyCPU</Platforms>
-    <TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
+    <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
     <Configurations>Debug;Release</Configurations>
     <LangVersion>latest</LangVersion>
     <RootNamespace>log4net</RootNamespace>
@@ -97,7 +97,7 @@
   <PropertyGroup Condition="'$(TargetFramework)'=='net40'">
     <DefineConstants>$(DefineConstants);NET_2_0;NET_4_0</DefineConstants>
   </PropertyGroup>
-  <PropertyGroup Condition="'$(TargetFramework)'=='net462'">
+  <PropertyGroup Condition="'$(TargetFramework)'=='net471'">
     
<DefineConstants>$(DefineConstants);NET_2_0;NET_4_0;NET_4_5</DefineConstants>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)'=='Debug' ">

Reply via email to