diff --git a/src/build-preview.ps1 b/src/build-preview.ps1
index c824735b..0c71fb20 100644
--- a/src/build-preview.ps1
+++ b/src/build-preview.ps1
@@ -1 +1 @@
-dotnet build -c Release '-p:GeneratePackages=true;VersionSuffix=preview.2' ./log4net/log4net.csproj
\ No newline at end of file
+dotnet build -c Release '-p:GeneratePackages=true;VersionSuffix=preview.4' ./log4net/log4net.csproj
\ No newline at end of file
diff --git a/src/log4net/Appender/FileAppender.cs b/src/log4net/Appender/FileAppender.cs
index 15131146..5be9ab8e 100644
--- a/src/log4net/Appender/FileAppender.cs
+++ b/src/log4net/Appender/FileAppender.cs
@@ -86,7 +86,7 @@ public class FileAppender : TextWriterAppender
///
private sealed class LockingStream : Stream, IDisposable
{
- [Serializable]
+ [Log4NetSerializable]
public sealed class LockStateException : LogException
{
public LockStateException(string message)
diff --git a/src/log4net/Config/AliasRepositoryAttribute.cs b/src/log4net/Config/AliasRepositoryAttribute.cs
index 39373331..2d7002d0 100644
--- a/src/log4net/Config/AliasRepositoryAttribute.cs
+++ b/src/log4net/Config/AliasRepositoryAttribute.cs
@@ -41,7 +41,7 @@ namespace log4net.Config
/// Nicko Cadell
/// Gert Driesen
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- [Serializable]
+ [Log4NetSerializable]
public sealed class AliasRepositoryAttribute : Attribute
{
///
diff --git a/src/log4net/Config/PluginAttribute.cs b/src/log4net/Config/PluginAttribute.cs
index 9ef26e61..c9110b24 100644
--- a/src/log4net/Config/PluginAttribute.cs
+++ b/src/log4net/Config/PluginAttribute.cs
@@ -39,7 +39,7 @@ namespace log4net.Config
/// Nicko Cadell
/// Gert Driesen
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- [Serializable]
+ [Log4NetSerializable]
public sealed class PluginAttribute : Attribute, IPluginFactory
{
///
diff --git a/src/log4net/Config/RepositoryAttribute.cs b/src/log4net/Config/RepositoryAttribute.cs
index 59514517..ccf4efb7 100644
--- a/src/log4net/Config/RepositoryAttribute.cs
+++ b/src/log4net/Config/RepositoryAttribute.cs
@@ -42,7 +42,7 @@ namespace log4net.Config
/// Nicko Cadell
/// Gert Driesen
[AttributeUsage(AttributeTargets.Assembly)]
- [Serializable]
+ [Log4NetSerializable]
public sealed class RepositoryAttribute : Attribute
{
///
diff --git a/src/log4net/Config/SecurityContextProviderAttribute.cs b/src/log4net/Config/SecurityContextProviderAttribute.cs
index e82e858e..e8edeee2 100644
--- a/src/log4net/Config/SecurityContextProviderAttribute.cs
+++ b/src/log4net/Config/SecurityContextProviderAttribute.cs
@@ -42,7 +42,7 @@ namespace log4net.Config
///
/// Nicko Cadell
[AttributeUsage(AttributeTargets.Assembly)]
- [Serializable]
+ [Log4NetSerializable]
public sealed class SecurityContextProviderAttribute : ConfiguratorAttribute
{
///
diff --git a/src/log4net/Config/XmlConfiguratorAttribute.cs b/src/log4net/Config/XmlConfiguratorAttribute.cs
index aee8389c..24411cbd 100644
--- a/src/log4net/Config/XmlConfiguratorAttribute.cs
+++ b/src/log4net/Config/XmlConfiguratorAttribute.cs
@@ -76,7 +76,7 @@ namespace log4net.Config
/// Nicko Cadell
/// Gert Driesen
[AttributeUsage(AttributeTargets.Assembly)]
- [Serializable]
+ [Log4NetSerializable]
public sealed class XmlConfiguratorAttribute : ConfiguratorAttribute
{
///
diff --git a/src/log4net/Core/Level.cs b/src/log4net/Core/Level.cs
index e15078b6..3027fb58 100644
--- a/src/log4net/Core/Level.cs
+++ b/src/log4net/Core/Level.cs
@@ -82,8 +82,8 @@ namespace log4net.Core;
///
/// Nicko Cadell
/// Gert Driesen
-[Serializable]
-public class Level : IComparable, ISerializable, IEquatable, IComparable
+[Log4NetSerializable]
+public class Level : IComparable, ILog4NetSerializable, IEquatable, IComparable
{
///
/// Constructor
diff --git a/src/log4net/Core/LocationInfo.cs b/src/log4net/Core/LocationInfo.cs
index 2ce29ae0..3e1c3ef0 100644
--- a/src/log4net/Core/LocationInfo.cs
+++ b/src/log4net/Core/LocationInfo.cs
@@ -57,8 +57,8 @@ namespace log4net.Core
///
/// Nicko Cadell
/// Gert Driesen
- [Serializable]
- public class LocationInfo : ISerializable
+ [Log4NetSerializable]
+ public class LocationInfo : ILog4NetSerializable
{
///
/// Constructor
diff --git a/src/log4net/Core/LogException.cs b/src/log4net/Core/LogException.cs
index 33a604d3..762eb384 100644
--- a/src/log4net/Core/LogException.cs
+++ b/src/log4net/Core/LogException.cs
@@ -34,7 +34,7 @@ namespace log4net.Core
///
/// Nicko Cadell
/// Gert Driesen
- [Serializable]
+ [Log4NetSerializable]
public class LogException : ApplicationException
{
///
diff --git a/src/log4net/Core/LoggingEvent.cs b/src/log4net/Core/LoggingEvent.cs
index 48d2e25f..8cfadf51 100644
--- a/src/log4net/Core/LoggingEvent.cs
+++ b/src/log4net/Core/LoggingEvent.cs
@@ -164,8 +164,8 @@ public struct LoggingEventData
/// Gert Driesen
/// Douglas de la Torre
/// Daniel Cazzulino
- [Serializable]
- public class LoggingEvent : ISerializable
+ [Log4NetSerializable]
+ public class LoggingEvent : ILog4NetSerializable
{
private static readonly Type declaringType = typeof(LoggingEvent);
diff --git a/src/log4net/Core/MethodItem.cs b/src/log4net/Core/MethodItem.cs
index 5e8314bb..5c8d02c6 100644
--- a/src/log4net/Core/MethodItem.cs
+++ b/src/log4net/Core/MethodItem.cs
@@ -28,7 +28,7 @@ namespace log4net.Core
/// as that would require that the containing assembly is loaded.
///
///
- [Serializable]
+ [Log4NetSerializable]
public class MethodItem
{
///
diff --git a/src/log4net/Core/Serializable.cs b/src/log4net/Core/Serializable.cs
new file mode 100644
index 00000000..b88f0612
--- /dev/null
+++ b/src/log4net/Core/Serializable.cs
@@ -0,0 +1,24 @@
+#if NET462_OR_GREATER
+global using Log4NetSerializableAttribute = System.SerializableAttribute;
+global using ILog4NetSerializable = System.Runtime.Serialization.ISerializable;
+#else
+global using Log4NetSerializableAttribute = log4net.Core.EmptyAttribute;
+global using ILog4NetSerializable = log4net.Core.IEmptyInterface;
+using System;
+#endif
+
+namespace log4net.Core;
+#if !NET462_OR_GREATER
+///
+/// Empty Interface (as replacement for )
+///
+internal interface IEmptyInterface
+{ }
+
+///
+/// Empty Attribute (as replacement for )
+///
+[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate, Inherited = false)]
+internal sealed class EmptyAttribute : Attribute
+{ }
+#endif
\ No newline at end of file
diff --git a/src/log4net/Core/StackFrameItem.cs b/src/log4net/Core/StackFrameItem.cs
index a27d7037..6cf2f782 100644
--- a/src/log4net/Core/StackFrameItem.cs
+++ b/src/log4net/Core/StackFrameItem.cs
@@ -28,7 +28,7 @@ namespace log4net.Core
/// Provides stack frame information without actually referencing a System.Diagnostics.StackFrame
/// as that would require that the containing assembly is loaded.
///
- [Serializable]
+ [Log4NetSerializable]
public class StackFrameItem
{
///
diff --git a/src/log4net/Util/EmptyCollection.cs b/src/log4net/Util/EmptyCollection.cs
index 708370ca..30082648 100644
--- a/src/log4net/Util/EmptyCollection.cs
+++ b/src/log4net/Util/EmptyCollection.cs
@@ -33,7 +33,7 @@ namespace log4net.Util
///
/// Nicko Cadell
/// Gert Driesen
- [Serializable]
+ [Log4NetSerializable]
public sealed class EmptyCollection : ICollection
{
///
diff --git a/src/log4net/Util/EmptyDictionary.cs b/src/log4net/Util/EmptyDictionary.cs
index 9ed11b08..fbee5305 100644
--- a/src/log4net/Util/EmptyDictionary.cs
+++ b/src/log4net/Util/EmptyDictionary.cs
@@ -33,7 +33,7 @@ namespace log4net.Util
///
/// Nicko Cadell
/// Gert Driesen
- [Serializable]
+ [Log4NetSerializable]
public sealed class EmptyDictionary : IDictionary
{
///
diff --git a/src/log4net/Util/PropertiesDictionary.cs b/src/log4net/Util/PropertiesDictionary.cs
index 3f2c1064..b6682b66 100644
--- a/src/log4net/Util/PropertiesDictionary.cs
+++ b/src/log4net/Util/PropertiesDictionary.cs
@@ -36,8 +36,8 @@ namespace log4net.Util
///
/// Nicko Cadell
/// Gert Driesen
- [Serializable]
- public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ISerializable, IDictionary
+ [Log4NetSerializable]
+ public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ILog4NetSerializable, IDictionary
{
///
/// Constructor
diff --git a/src/log4net/Util/ReadOnlyPropertiesDictionary.cs b/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
index 2c347961..d2973218 100644
--- a/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
+++ b/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
@@ -40,8 +40,8 @@ namespace log4net.Util
///
/// Nicko Cadell
/// Gert Driesen
- [Serializable]
- public class ReadOnlyPropertiesDictionary : ISerializable, IDictionary, IDictionary
+ [Log4NetSerializable]
+ public class ReadOnlyPropertiesDictionary : ILog4NetSerializable, IDictionary, IDictionary
{
private const string ReadOnlyMessage = "This is a read-only dictionary and cannot be modified";
diff --git a/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs b/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
index 6d33310e..6a351af3 100644
--- a/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
+++ b/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
@@ -34,7 +34,7 @@ namespace log4net.Util.TypeConverters
///
/// Nicko Cadell
/// Gert Driesen
- [Serializable]
+ [Log4NetSerializable]
public class ConversionNotSupportedException : ApplicationException
{
///
diff --git a/src/site/xdoc/release/release-notes.xml b/src/site/xdoc/release/release-notes.xml
index 1441b258..54ff489d 100644
--- a/src/site/xdoc/release/release-notes.xml
+++ b/src/site/xdoc/release/release-notes.xml
@@ -137,6 +137,10 @@ limitations under the License.
log4net.Appender.NetSendAppender
NetSendAdapter removed
+
+ Serializable Support removed (for .netstandard)
+ Removing legacy serialization from log4net
+