nicko       2005/06/20 12:35:26

  Modified:    src/Util LogLog.cs
  Log:
  Fix for LOG4NET-36 System.Diagnostics.Trace may throw exception if AppDomain 
does not have config file. Added try catch blocks
  
  Revision  Changes    Path
  1.7       +38 -12    logging-log4net/src/Util/LogLog.cs
  
  Index: LogLog.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Util/LogLog.cs,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LogLog.cs 31 Jan 2005 22:56:49 -0000      1.6
  +++ LogLog.cs 20 Jun 2005 19:35:25 -0000      1.7
  @@ -370,19 +370,32 @@
                /// <param name="message">The message to log.</param>

                /// <remarks>

                /// <para>

  -             /// Uses Console.Out for console output,

  -             /// and Trace for OutputDebugString output.

  +             /// Writes to both Console.Out and System.Diagnostics.Trace.

  +             /// Note that the System.Diagnostics.Trace is not supported

  +             /// on the Compact Framework.

  +             /// </para>

  +             /// <para>

  +             /// If the AppDomain is not configured with a config file then

  +             /// the call to System.Diagnostics.Trace may fail. This is only

  +             /// an issue if you are programmatically creating your own 
AppDomains.

                /// </para>

                /// </remarks>

                private static void EmitOutLine(string message)

                {

  +                     try

  +                     {

   #if NETCF

  -                     Console.WriteLine(message);

  -                     //System.Diagnostics.Debug.WriteLine(message);

  +                             Console.WriteLine(message);

  +                             //System.Diagnostics.Debug.WriteLine(message);

   #else

  -                     Console.Out.WriteLine(message);

  -                     Trace.WriteLine(message);

  +                             Console.Out.WriteLine(message);

  +                             Trace.WriteLine(message);

   #endif

  +                     }

  +                     catch

  +                     {

  +                             // Ignore exception, what else can we do? Not 
really a good idea to propagate back to the caller

  +                     }

                }

   

                /// <summary>

  @@ -391,19 +404,32 @@
                /// <param name="message">The message to log.</param>

                /// <remarks>

                /// <para>

  -             /// Use Console.Error for console output,

  -             /// and Trace for OutputDebugString output.

  +             /// Writes to both Console.Error and System.Diagnostics.Trace.

  +             /// Note that the System.Diagnostics.Trace is not supported

  +             /// on the Compact Framework.

  +             /// </para>

  +             /// <para>

  +             /// If the AppDomain is not configured with a config file then

  +             /// the call to System.Diagnostics.Trace may fail. This is only

  +             /// an issue if you are programmatically creating your own 
AppDomains.

                /// </para>

                /// </remarks>

                private static void EmitErrorLine(string message)

                {

  +                     try

  +                     {

   #if NETCF

  -                     Console.WriteLine(message);

  -                     //System.Diagnostics.Debug.WriteLine(message);

  +                             Console.WriteLine(message);

  +                             //System.Diagnostics.Debug.WriteLine(message);

   #else

  -                     Console.Error.WriteLine(message);

  -                     Trace.WriteLine(message);

  +                             Console.Error.WriteLine(message);

  +                             Trace.WriteLine(message);

   #endif

  +                     }

  +                     catch

  +                     {

  +                             // Ignore exception, what else can we do? Not 
really a good idea to propagate back to the caller

  +                     }

                }

   

                #region Private Static Fields

  
  
  

Reply via email to