Index: Core/LoggingEvent.cs
===================================================================
--- Core/LoggingEvent.cs (revision 330682)
+++ Core/LoggingEvent.cs (working copy)
@@ -827,7 +827,7 @@
{
#if (NETCF || SSCLI)
// On compact framework there's no notion of current Windows user
- m_data.UserName = "NOT AVAILABLE";
+ m_data.UserName = SystemInfo.NotAvailableText;
#else
try
{
@@ -875,7 +875,7 @@
{
#if (NETCF || SSCLI)
// On compact framework there's no notion of current thread principals
- m_data.Identity = "NOT AVAILABLE";
+ m_data.Identity = SystemInfo.NotAvailableText;
#else
try
{
Index: ObjectRenderer/DefaultRenderer.cs
===================================================================
--- ObjectRenderer/DefaultRenderer.cs (revision 330682)
+++ ObjectRenderer/DefaultRenderer.cs (working copy)
@@ -17,7 +17,6 @@
#endregion
using System;
-using System.Text;
using System.IO;
using System.Collections;
@@ -40,8 +39,6 @@
/// Gert Driesen
public sealed class DefaultRenderer : IObjectRenderer
{
- private static readonly string NewLine = SystemInfo.NewLine;
-
#region Constructors
///
@@ -144,7 +141,7 @@
if (obj == null)
{
- writer.Write("(null)");
+ writer.Write(SystemInfo.NullText);
return;
}
@@ -169,7 +166,7 @@
}
string str = obj.ToString();
- writer.Write( (str==null) ? "(null)" : str );
+ writer.Write( (str==null) ? SystemInfo.NullText : str );
}
#endregion
Index: ObjectRenderer/RendererMap.cs
===================================================================
--- ObjectRenderer/RendererMap.cs (revision 330682)
+++ ObjectRenderer/RendererMap.cs (working copy)
@@ -18,6 +18,7 @@
using System;
using System.IO;
+using log4net.Util;
namespace log4net.ObjectRenderer
{
@@ -109,7 +110,7 @@
{
if (obj == null)
{
- writer.Write("(null)");
+ writer.Write(SystemInfo.NullText);
}
else
{
Index: Repository/Hierarchy/XmlHierarchyConfigurator.cs
===================================================================
--- Repository/Hierarchy/XmlHierarchyConfigurator.cs (revision 330682)
+++ Repository/Hierarchy/XmlHierarchyConfigurator.cs (working copy)
@@ -18,6 +18,7 @@
using System;
using System.Collections;
+using System.Configuration;
using System.Globalization;
using System.Reflection;
using System.Xml;
@@ -99,7 +100,7 @@
string debugAttribute = element.GetAttribute(INTERNAL_DEBUG_ATTR);
LogLog.Debug("XmlHierarchyConfigurator: "+INTERNAL_DEBUG_ATTR+" attribute [" + debugAttribute + "].");
- if (debugAttribute.Length>0 && debugAttribute != "null")
+ if (debugAttribute.Length > 0 && debugAttribute != "null")
{
LogLog.InternalDebugging = OptionConverter.ToBoolean(debugAttribute, true);
}
@@ -109,7 +110,7 @@
}
string confDebug = element.GetAttribute(CONFIG_DEBUG_ATTR);
- if (confDebug.Length>0 && confDebug != "null")
+ if (confDebug.Length > 0 && confDebug != "null")
{
LogLog.Warn("XmlHierarchyConfigurator: The \"" + CONFIG_DEBUG_ATTR + "\" attribute is deprecated.");
LogLog.Warn("XmlHierarchyConfigurator: Use the \"" + INTERNAL_DEBUG_ATTR + "\" attribute instead.");
@@ -117,6 +118,26 @@
}
}
+#if !NETCF
+ // Look for log4net.NullText in AppSettings
+ string nullTextAppSettingsKey = ConfigurationSettings.AppSettings["log4net.NullText"];
+ if (nullTextAppSettingsKey != null && nullTextAppSettingsKey.Length > 0)
+ {
+ LogLog.Debug("XmlHierarchyConfigurator: Replacing default SystemInfo.NullText value [" + SystemInfo.NullText + "] with [" + nullTextAppSettingsKey + "].");
+ SystemInfo.NullText = nullTextAppSettingsKey;
+ }
+#endif
+
+#if !NETCF
+ // Look for log4net.NotAvailableText in AppSettings
+ string notAvailableTextAppSettingsKey = ConfigurationSettings.AppSettings["log4net.NotAvailableText"];
+ if (notAvailableTextAppSettingsKey != null && notAvailableTextAppSettingsKey.Length > 0)
+ {
+ LogLog.Debug("XmlHierarchyConfigurator: Replacing default SystemInfo.NotAvailableText value [" + SystemInfo.NotAvailableText + "] with [" + notAvailableTextAppSettingsKey + "].");
+ SystemInfo.NotAvailableText = notAvailableTextAppSettingsKey;
+ }
+#endif
+
// Default mode is merge
ConfigUpdateMode configUpdateMode = ConfigUpdateMode.Merge;
@@ -1033,6 +1054,8 @@
private const string ADDITIVITY_ATTR = "additivity";
private const string THRESHOLD_ATTR = "threshold";
private const string CONFIG_DEBUG_ATTR = "configDebug";
+ private const string NULL_TEXT_ATTR = "nullText";
+ private const string NOT_AVAILABLE_TEXT_ATTR = "notAvailableText";
private const string INTERNAL_DEBUG_ATTR = "debug";
private const string CONFIG_UPDATE_MODE_ATTR = "update";
private const string RENDERING_TYPE_ATTR = "renderingClass";
@@ -1057,4 +1080,4 @@
#endregion Private Instance Fields
}
-}
+}
\ No newline at end of file
Index: Util/PatternConverter.cs
===================================================================
--- Util/PatternConverter.cs (revision 330682)
+++ Util/PatternConverter.cs (working copy)
@@ -16,12 +16,10 @@
//
#endregion
-using System;
using System.Text;
using System.IO;
using System.Collections;
-using log4net.Core;
using log4net.Util;
using log4net.Repository;
@@ -339,7 +337,7 @@
// Don't have a repository to render with so just have to rely on ToString
if (value == null)
{
- writer.Write( "(null)" );
+ writer.Write( SystemInfo.NullText );
}
else
{
Index: Util/PatternStringConverters/IdentityPatternConverter.cs
===================================================================
--- Util/PatternStringConverters/IdentityPatternConverter.cs (revision 330682)
+++ Util/PatternStringConverters/IdentityPatternConverter.cs (working copy)
@@ -16,8 +16,6 @@
//
#endregion
-using System;
-using System.Text;
using System.IO;
using log4net.Util;
@@ -49,7 +47,7 @@
{
#if (NETCF || SSCLI)
// On compact framework there's no notion of current thread principals
- writer.Write( "NOT AVAILABLE" );
+ writer.Write( SystemInfo.NotAvailableText );
#else
try
{
@@ -66,7 +64,7 @@
// some undefined set of SecurityPermission flags.
LogLog.Debug("IdentityPatternConverter: Security exception while trying to get current thread principal. Error Ignored.");
- writer.Write( "NOT AVAILABLE" );
+ writer.Write( SystemInfo.NotAvailableText );
}
#endif
}
Index: Util/PatternStringConverters/ProcessIdPatternConverter.cs
===================================================================
--- Util/PatternStringConverters/ProcessIdPatternConverter.cs (revision 330682)
+++ Util/PatternStringConverters/ProcessIdPatternConverter.cs (working copy)
@@ -16,8 +16,6 @@
//
#endregion
-using System;
-using System.Text;
using System.IO;
using log4net.Util;
@@ -49,7 +47,7 @@
{
#if (NETCF || SSCLI)
// On compact framework there is no System.Diagnostics.Process class
- writer.Write( "NOT AVAILABLE" );
+ writer.Write( SystemInfo.NotAvailableText );
#else
try
{
@@ -61,7 +59,7 @@
// some undefined set of SecurityPermission flags.
LogLog.Debug("ProcessIdPatternConverter: Security exception while trying to get current process id. Error Ignored.");
- writer.Write( "NOT AVAILABLE" );
+ writer.Write( SystemInfo.NotAvailableText );
}
#endif
}
Index: Util/PatternStringConverters/UserNamePatternConverter.cs
===================================================================
--- Util/PatternStringConverters/UserNamePatternConverter.cs (revision 330682)
+++ Util/PatternStringConverters/UserNamePatternConverter.cs (working copy)
@@ -16,8 +16,6 @@
//
#endregion
-using System;
-using System.Text;
using System.IO;
using log4net.Util;
@@ -49,7 +47,7 @@
{
#if (NETCF || SSCLI)
// On compact framework there's no notion of current Windows user
- writer.Write( "NOT AVAILABLE" );
+ writer.Write( SystemInfo.NotAvailableText );
#else
try
{
@@ -66,7 +64,7 @@
// some undefined set of SecurityPermission flags.
LogLog.Debug("UserNamePatternConverter: Security exception while trying to get current windows identity. Error Ignored.");
- writer.Write( "NOT AVAILABLE" );
+ writer.Write( SystemInfo.NotAvailableText );
}
#endif
}
Index: Util/SystemInfo.cs
===================================================================
--- Util/SystemInfo.cs (revision 330682)
+++ Util/SystemInfo.cs (working copy)
@@ -53,6 +53,24 @@
#endregion Private Instance Constructors
+ #region Public Static Constructor
+
+ ///
+ /// Initialize default values for private static fields.
+ ///
+ ///
+ ///
+ /// Only static methods are exposed from this type.
+ ///
+ ///
+ static SystemInfo()
+ {
+ s_notAvailableText = "NOT AVAILABLE";
+ s_nullText = "(null)";
+ }
+
+ #endregion
+
#region Public Static Properties
///
@@ -239,7 +257,7 @@
// Couldn't find a value
if (s_hostName == null || s_hostName.Length == 0)
{
- s_hostName = "NOT AVAILABLE";
+ s_hostName = s_notAvailableText;
}
}
return s_hostName;
@@ -295,15 +313,13 @@
if (s_appFriendlyName == null || s_appFriendlyName.Length == 0)
{
- s_appFriendlyName = "NOT AVAILABLE";
+ s_appFriendlyName = s_notAvailableText;
}
}
return s_appFriendlyName;
}
}
- private static DateTime s_processStartTime = DateTime.Now;
-
///
/// Get the start time for the current process.
///
@@ -329,6 +345,35 @@
get { return s_processStartTime; }
}
+ ///
+ /// Text to output when a null is encountered.
+ ///
+ ///
+ ///
+ /// Use this value to indicate a null has been encountered while
+ /// outputing a string representation of an item.
+ ///
+ ///
+ public static string NullText
+ {
+ get { return s_nullText; }
+ set { s_nullText = value; }
+ }
+
+ ///
+ /// Text to output when an unsupported feature is requested.
+ ///
+ ///
+ ///
+ /// Use this value when an unsupported feature is requested.
+ ///
+ ///
+ public static string NotAvailableText
+ {
+ get { return s_notAvailableText; }
+ set { s_notAvailableText = value; }
+ }
+
#endregion Public Static Properties
#region Public Static Methods
@@ -858,6 +903,21 @@
///
private static string s_appFriendlyName;
+ ///
+ /// Text to output when a null is encountered.
+ ///
+ private static string s_nullText;
+
+ ///
+ /// Text to output when an unsupported feature is requested.
+ ///
+ private static string s_notAvailableText;
+
+ ///
+ /// Start time for the current process.
+ ///
+ private static DateTime s_processStartTime = DateTime.Now;
+
#endregion
#region Compact Framework Helper Classes
Index: Util/ThreadContextStacks.cs
===================================================================
--- Util/ThreadContextStacks.cs (revision 330682)
+++ Util/ThreadContextStacks.cs (working copy)
@@ -16,9 +16,6 @@
//
#endregion
-using System;
-using System.Collections;
-
namespace log4net.Util
{
///
@@ -84,7 +81,7 @@
if (stack == null)
{
// Property is not set to a stack!
- string propertyValueString = "(null)";
+ string propertyValueString = SystemInfo.NullText;
try
{