logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: log4net is truncating log messages with %20.20type{1}.%-30.30method in the ConversionPattern
Date Fri, 22 Dec 2006 04:10:52 GMT
Does this code demonstrate the problem at all? I get the same results from .NET 1.1 and 2.0:

using System;
using System.Runtime.CompilerServices;
using log4net;
using log4net.Appender;
using log4net.Config;
using log4net.Layout;

namespace ConsoleApplication2
{
    class Class1
    {
        private readonly static ILog log = LogManager.GetLogger(typeof(Class1));

        [STAThread]
        static void Main(string[] args)
        {
            ConsoleAppender consoleAppender = new ConsoleAppender();
            consoleAppender.Layout = new PatternLayout("%20.20type{1}.%-30.30method %message%newline");
            BasicConfigurator.Configure(consoleAppender);
            log.Info("Application starting.");

            OneTwoThreeFourFiveSixSevenEightNineTen numbers =
                new OneTwoThreeFourFiveSixSevenEightNineTen();

            numbers.TenNineEightSevenSixFiveFourThreeTwoOne();
        }
    }

    public class OneTwoThreeFourFiveSixSevenEightNineTen
    {
        private readonly static ILog log = 
            LogManager.GetLogger(typeof(OneTwoThreeFourFiveSixSevenEightNineTen));

        public void TenNineEightSevenSixFiveFourThreeTwoOne()
        {
            log.Debug("Hello World");
        }
    }
}

It produces the following output in Debug mode:

              Class1.Main                           Application starting.
SixSevenEightNineTen.ghtSevenSixFiveFourThreeTwoOne Hello World

and the following output in Release mode:

              Class1.Main                           Application starting.
              Class1.Main                           Hello World

The long class and method names look like they're being truncated at 20 and 30 characters
respectively. Adding this attribute to the TenNineEight... method:

[MethodImpl(MethodImplOptions.NoInlining)]

made the output the same for both builds. Does your problem go away when your add the NoInlining
option? I don't know if its possible to code around compiler optimizations.

----- Original Message ----

From: Drew Burlingame <drewburlingame@gmail.com>

To: log4net-user@logging.apache.org

Sent: Wednesday, December 20, 2006 6:31:58 PM

Subject: log4net is truncating log messages with %20.20type{1}.%-30.30method in the ConversionPattern



we've encountered a problem where log4net is truncating log messages (samples below).  The
truncating only happens when we compile in release and the ConversionPattern includes %20.20type{1}.%-30.30method.
 I'm assuming it has to do with the code optimizations interfering with log4net.  What can
we do to get the release logging to work correctly? 



Thanks,

Drew



 environment:

 - version 1.2.10.0

 - framwork: 2.0

 - os: xp and 2003



release:



DEV   |20061220-16:40:01.754|            1| INFO  |20061220-16:40:01.848|    ChnSrvr:7|  
   CommandLineHost.StartService                   | Starting channel server in a thread

 INFO  |20061220-16:40:14.176|    ChnSrvr:7|        ChannelServer.StartServer            
       | Channel server is loading backchat cache

DEBUG |20061220-16:40:14.223|    ChnSrvr:7| DEBUG |20061220-16:40:14.223|    ChnSrvr:7| TRACE
|20061220-16:40: 14.317|    ChnSrvr:7|    ServerNodeManager.set_Domain                   
 | Domain for ServerNodeManager set to <example.com>



debug:



DEV   |20061220-16:04:20.219|            1|          TimerService.setNewTimer            
       | Setting new timerinterval of <15> seconds

INFO  |20061220-16:04:20.297|    ChnSrvr:7|      CommandLineHost.StartService            
      | Starting channel server in a thread 

INFO  |20061220-16:04:38.063|    ChnSrvr:7|        ChannelServer.StartServer             
      | Channel server is loading backchat cache

DEBUG |20061220-16:04:38.094|    ChnSrvr:7|     ParlanoSqlHelper.logSproc                
      | exec procSearchForNodes 0, '', 0 

DEBUG |20061220-16:04:38.094|    ChnSrvr:7|     ParlanoSqlHelper.ExecuteReader           
      | loading data with <<get_RunLoadIdsDelegate>b__0>

TRACE |20061220-16:04:38.172|    ChnSrvr:7|    ServerNodeManager.set_Domain              
       | Domain for ServerNodeManager set to <example.com>





 








Mime
View raw message