From: Stephen B. <sb...@gm...> - 2012-12-14 14:55:48
|
Hmm...I have to agree that sounds like a Common.Logging issue after all -- thanks for your help in trying to better isolate the problem. Can you open an issue here https://github.com/net-commons/common-logging/issues?state=open and we'll try to look into it for you soon --? Thanks again, -Steve B. Steve Bohlen sb...@gm... http://blog.unhandled-exceptions.com http://twitter.com/sbohlen On Fri, Dec 14, 2012 at 9:47 AM, Peter Kirk <pk...@al...> wrote: > Hi – thanks for your reply.**** > > ** ** > > If I try the following, then the failure occurs when passing the lambda > expression to common.logging.**** > > So log4net itself, and the non-lambda call to common-logging work fine. > But when trying to pass the lambda, common-logging doesn’t like it.**** > > ** ** > > log4net.Config.XmlConfigurator.Configure(new FileInfo("log4net.config"));* > *** > > log4net.ILog log4netLog = log4net.LogManager.GetLogger("TestApp");**** > > ** ** > > Common.Logging.ILog commonLog = Common.Logging.LogManager > .GetCurrentClassLogger();**** > > ** ** > > log4netLog.Debug("log4net {a}");**** > > commonLog.Debug("common logging {a}");**** > > commonLog.Debug(m => m("common logging lambda {a}"));**** > > ** ** > > ** ** > > /Peter**** > > ** ** > > ** ** > > *From:* Stephen Bohlen [mailto:sb...@gm...] > *Sent:* 14. december 2012 14:40 > *To:* Peter Kirk > *Cc:* net...@li... > *Subject:* Re: [Netcommon-developer] Common.Logging: : Input string was > not in a correct format**** > > ** ** > > 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**** > > ** ** > |