From: Stephen B. <sb...@gm...> - 2012-12-14 13:39:47
|
I am nearly certain that this issue is coming from Log4Net rather than Common.Logging. Assuming this email contains your full stack trace, you can see this too by noting the root exception seems to originate from log4net.ObjectRenderer.RendererMap.FindAndRender(Object obj, TextWriter writer). IIRC in Log4Net the { } characters are used as replacement tokens in log message formatting strings and so are probably either reserved entirely or need to be escaped. Common.Logging isn't doing any 'processing' of the log messages, merely passing them off to whatever logging framework you're using so I'd start there. The simplest way to confirm this would probably be to try to wire up log4net to a test class of your own and forcibly try to process a log message like... log.Debug(m => m("this is a test with some { and } characters")); ...and see if log4net can handle that 'natively' using your same log4net configuration/logging format settings. Let us know if this helps~! -Steve B. Steve Bohlen sb...@gm... http://blog.unhandled-exceptions.com http://twitter.com/sbohlen On Fri, Dec 14, 2012 at 5:13 AM, Peter Kirk <pk...@al...> wrote: > Hi, I am using common.logging (with log4net 1.2.10). Sometimes, when I > try to log a string which I received from an external service, the logging > system throws an exception. I am not sure if the exception originates from > common.logging or log4net. **** > > ** ** > > For example, I do:**** > > string s = service.GetName();**** > > log.Debug(m => m("servicename=" + s));**** > > ** ** > > It appears this exception occurs because the string contains ‘{‘ and/or > ‘}’ characters. Can this be correct? (Maybe the name I get is > "Service81{loc17}").**** > > ** ** > > <log4net.Error>Exception rendering object type > [Common.Logging.Factory.AbstractLogger+FormatMessageCallbackFormattedMessage]<stackTrace>System.FormatException: > Input string was not in a correct format.**** > > at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, > String format, Object[] args)**** > > at System.String.Format(IFormatProvider provider, String format, > Object[] args)**** > > at > Common.Logging.Factory.AbstractLogger.FormatMessageCallbackFormattedMessage.FormatMessage(String > format, Object[] args)**** > > at > Alpha.Portal.ServiceAccess.Search.<>c__DisplayClass6.<AllContent>b__5(FormatMessageHandler > m)**** > > at > Common.Logging.Factory.AbstractLogger.FormatMessageCallbackFormattedMessage.ToString() > **** > > at log4net.ObjectRenderer.DefaultRenderer.RenderObject(RendererMap > rendererMap, Object obj, TextWriter writer)**** > > at log4net.ObjectRenderer.RendererMap.FindAndRender(Object obj, > TextWriter writer)</stackTrace></log4net.Error>**** > > ** ** > > Thanks for any comments,**** > > Peter**** > > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > Netcommon-developer mailing list > Net...@li... > https://lists.sourceforge.net/lists/listinfo/netcommon-developer > > |