1

I would like to use Sharedcache (sharedcache.codeplex.com) in our Silverlight v4.0 project. However, we are using NLog v2.0 for the client logging. SharedCache currently release only support NLog v1.1 which will collide with NLog v2.0 on our web server.

So I decided to convert Sharedcache windows service to use NLog v2.0. The compilation was successful. But as soon as I start the service, I got this error. Can somebody familiar with NLog help? I think it is complaining about the layout.

Here is the windows service configuration file:

  <nlog autoReload="true" throwExceptions="true">
<targets async="true">
  <target name="shared_cache_general" type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\server\${date:format=yyyy-MM-dd}_shared_cache_general_log.txt"/>
  <target name="shared_cache_traffic" type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\server\${date:format=yyyy-MM-dd}_shared_cache_traffic_log.txt"/>
  <target name="shared_cache_tracking" type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\server\${date:format=yyyy-MM-dd}_shared_cache_tracking_log.txt"/>
  <target name="shared_cache_sync" type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\server\${date:format=yyyy-MM-dd}_shared_cache_sync_log.txt"/>
  <target name="shared_cache_memory" type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\server\${date:format=yyyy-MM-dd}_shared_cache_memory_log.txt"/>
</targets>
<rules>
  <logger name="General" minlevel="Debug" writeTo="shared_cache_general" final="true"/>
  <logger name="Traffic" minlevel="Debug" writeTo="shared_cache_traffic" final="true"/>
  <logger name="Tracking" minlevel="Debug" writeTo="shared_cache_tracking" final="true"/>
  <logger name="Sync" minlevel="Debug" writeTo="shared_cache_sync" final="true"/>
  <logger name="Memory" minlevel="Debug" writeTo="shared_cache_memory" final="true"/>
  <logger name="*" minlevel="Debug" writeTo="shared_cache_general"/>
  <logger name="*" minlevel="Info" writeTo="shared_cache_general"/>
</rules>

When I started the service in Visual Studio, I got the following NLog exception:

{"Error when setting property 'Layout' on File Target[shared_cache_general]"}


at NLog.Internal.PropertyHelper.SetPropertyFromString(Object o, String name, String value, ConfigurationItemFactory configurationItemFactory) in c:\NLogBuild\src\NLog\Internal\PropertyHelper.cs:line 107
   at NLog.Config.XmlLoggingConfiguration.ConfigureObjectFromAttributes(Object targetObject, NLogXmlElement element, Boolean ignoreType) in c:\NLogBuild\src\NLog\Config\XmlLoggingConfiguration.cs:line 828
   at NLog.Config.XmlLoggingConfiguration.ParseTargetElement(Target target, NLogXmlElement targetElement) in c:\NLogBuild\src\NLog\Config\XmlLoggingConfiguration.cs:line 562
   at NLog.Config.XmlLoggingConfiguration.ParseTargetsElement(NLogXmlElement targetsElement) in c:\NLogBuild\src\NLog\Config\XmlLoggingConfiguration.cs:line 538
   at NLog.Config.XmlLoggingConfiguration.ParseNLogElement(NLogXmlElement nlogElement, String baseDirectory) in c:\NLogBuild\src\NLog\Config\XmlLoggingConfiguration.cs:line 344
   at NLog.Config.XmlLoggingConfiguration.ParseTopLevel(NLogXmlElement content, String baseDirectory) in c:\NLogBuild\src\NLog\Config\XmlLoggingConfiguration.cs:line 301
   at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors) in c:\NLogBuild\src\NLog\Config\XmlLoggingConfiguration.cs:line 247
tonyjy
  • 1,359
  • 3
  • 12
  • 24
  • 1
    This is better asked at the forums at http://sharedcache.codeplex.com. As for "how easy is it to replace NLog v1.1 with NLog v2.0 in SharedCache": What have you tried? Post some code and tell us what is breaking. – Merlyn Morgan-Graham Sep 20 '11 at 17:53
  • I tried to compile the code with NLog v2.0 and converted the project to v2010 Visual Studio. It compiled successfully. However, it seems that the format for the config files were throwing exceptions. I am not familiar with NLog very much. So I can probably post NLog config file here. – tonyjy Sep 20 '11 at 17:59
  • 1
    That's a good idea and would put this more in the answerable category :) Can you post the exceptions you're getting, too? – Merlyn Morgan-Graham Sep 20 '11 at 17:59

1 Answers1

1

I figured it out. Just remove the following layout and it supports for NLog v2.0 now.

${aspnet-request:item=logSession}|
tonyjy
  • 1,359
  • 3
  • 12
  • 24