Facing Problems with Clog in SL.3.0

Oct 8, 2009 at 8:36 AM
Edited Oct 8, 2009 at 11:06 AM

Hi all,

I'm new to clog. As per the article, I have tried to create the sample logger for silverlight3.0. application. But I cant do it.

I have followed the following steps,

1. I have added the Daniel...logging.dll

2. Added Daniel...silverlight.dll

3. I have used the log.debug(message);

4. In Web project side, I have added the clog config section as well as log4net config also.

5. I have added the .svc file as given in the article.

Eventhough, I cant able to log the message, either by using "UdpAppender" or "FileAppender".

The problem is the "Client ConfigurationData" getting NULL, so that I'm getting the ClogService as NULL.

I'nt cross over from the issues.

Can any one please help me out to do the same. Please let me know if any more info needed,

Eagarly waiting for the reply,

Cheers...

Karthikeyan Manickam.

Coordinator
Oct 8, 2009 at 11:16 AM

Karthikeyan,

Are you able to log a message using Log4Net directly from your ASP.NET web application?

Oct 8, 2009 at 11:25 AM

Hi Daniel,

My Environment is .NET3.5, VS-2008-SP1, Silverlight3.0.

I'll give my code as follows,

MainPage.xaml.cs file :-

static readonly ILog log = LogManager.GetLog(typeof(MainPage));
        public MainPage()
        {
            InitializeComponent();
        }

        private void Commander_Click(object sender, RoutedEventArgs e)
        {
            log.Info("Test Message");
            log.Debug("Karthikeyan Manickam");
            MessageBox.Show("Logged....!");
        }

 

Web.config :-

<configSections>
  <section name="Clog" type="DanielVaughan.Logging.Configuration.ClientLoggingConfigurationSectionHandler, DanielVaughan.Logging"/>
  <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" requirePermission="false"/>
    </configSections>
 
 <appSettings/>
 <connectionStrings/>
 
 <Clog InternalLogLevel="All" SkipFrameCount="4" xmlns="http://danielvaughan.orpius.com/Clog/2/0/">
  <LogStrategy Name="Simple" Type="ExampleWebsite.SimpleLogStrategy, ExampleWebsite">
   <Filter Name="IPAddressRange" Type="DanielVaughan.Logging.Filters.IPAddressRangeFilter, DanielVaughan.Logging" Begin="127.0.0.0" End="127.0.0.10"/>
  </LogStrategy>
  <LogStrategy Name="Log4Net" Type="DanielVaughan.Logging.LogStrategies.Log4NetStrategy, DanielVaughan.Logging.Log4NetLogStrategy">
   <Filter Name="IPAddressRange" Type="DanielVaughan.Logging.Filters.IPAddressRangeFilter, DanielVaughan.Logging" Begin="127.0.0.0" End="127.0.0.10"/>
   <!-- Uncomment to prevent access to those users that
                 do now have membership of the specified roles. -->
   <!--
            <Filter Name="RoleMembership"
                type="DanielVaughan.Logging.Filters.RoleMembershipFilter,
                      DanielVaughan.Logging"
                Roles="Developer, Administrator" />
            -->
  </LogStrategy>
 </Clog>
 <!-- log4net [DV] -->
 <log4net debug="true">
  <!-- debug="true"  -->
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <param name="File" value="D:\\temp\\logsilverlight.txt"/>
      <param name="RemoteAddress" value="127.0.0.2" />
      <param name="RemotePort" value="8080" />
      <!-- Example using environment variables in params -->
      <!-- <param name="File" value="${TMP}\\ApplicationKit.log" /> -->
      <param name="AppendToFile" value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-2p %c [%x] - %m%n"/>
      </layout>
    </appender>
  <root>
   <level value="ALL"/>
   <appender-ref ref="FileAppender"/>
  </root>
  <!-- Clog requires url in logger names to be lower case.
   When using Clog on localhost, paths are relative. -->
  <logger name="SilverlightLoggerFrameworkApplication.MainPage,/default.aspx">
   <level value="INFO"/>
  </logger>
  <logger name="SilverlightLoggerFrameworkApplication.MainPage,http://www.orpius.com/innerpath/default.aspx">
   <level value="INFO"/>
  </logger>
 </log4net>

I'm getting the error as I mentioned in previous post, the ClientConfigurationData is getting NULL, so that I'm getting ClogService as NULL.

Here u go for my .svc file.

ClogService.svc :-

<font size="2">

<%

</font>

 

@ ServiceHost Language="C#" Debug="true" Service="DanielVaughan.Logging.ClogService"

%>

<font size="2"><font size="2" color="#0000ff"><font size="2" color="#0000ff"><font size="2">

Please help me out to resolve the issue.

Thanks in advance.

Cheers...

Karthikeyan Manickam.

</font></font></font></font><font size="2"><font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font></font><font size="2"><font size="2" color="#0000ff">

 

</font></font><font size="2">

 

</font>

 

Coordinator
Oct 8, 2009 at 12:12 PM

Clog is logging internally to Visual Studio's Output window during debugging. If you examine Clog's output does it mention any problems with a channel faulting?

Also, are you able to log serverside using Log4Net (not via Clog)?

 

Oct 8, 2009 at 12:57 PM

Hi Daniel,

While I'm debug through the code, I got the following errors in the output window while it's trying to create the channel.

Step into: Stepping over method without symbols 'System.Collections.Generic.Dictionary<System.Type,object>.TryGetValue'
Step into: Stepping over method without symbols 'System.ServiceModel.ChannelFactory<DanielVaughan.Logging.ClientLogging.IClogService>.ChannelFactory'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\en-US\System.ServiceModel.debug.resources.dll'
A first chance exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll
A first chance exception of type 'System.ArgumentException' occurred in System.ServiceModel.dll
A first chance exception of type 'System.ArgumentException' occurred in System.ServiceModel.dll

Please correct me If I'm wrong.

Thanks in advance,

Cheers...

Karthikeyan Manickam.

Coordinator
Oct 8, 2009 at 1:00 PM

In the Output window, look for Clog output. It occurs when Clog first starts up.

Oct 8, 2009 at 1:24 PM

Hi Daniel,

The following are my available in my output window. I couldn't properly find out the Clog starting point. Sorry for the inconvineance


'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\mscorlib.dll'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.Windows.Browser.dll'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.Windows.dll'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.Core.dll'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.Runtime.Serialization.dll'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\system.dll'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.Net.dll'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.Xml.dll'
'iexplore.exe' (Silverlight): Loaded 'SilverlightLoggerFrameworkApplication', Symbols loaded.
'iexplore.exe' (Silverlight): Loaded 'DanielVaughan', Symbols loaded.
'iexplore.exe' (Silverlight): Loaded 'DanielVaughan.Logging.Silverlight', Symbols loaded.
'iexplore.exe' (Silverlight): Loaded 'DanielVaughan.Logging.Silverlight.UI', Symbols loaded.
Step into: Stepping over method without symbols 'DanielVaughan.Logging.Log..'
Step into: Stepping over method without symbols 'object.Object'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'object.Object'
Step into: Stepping over method without symbols 'System.RuntimeType.AssemblyQualifiedName.get'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'int.Equals'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over property 'DanielVaughan.Logging.Log.Name.get'.  To step into properties, go to Tools->Options->Debugging and uncheck 'Step over properties and operators (Managed only)'.
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'System.Threading.Thread.CurrentThread.get'
Step into: Stepping over method without symbols 'System.Threading.Thread.Name.get'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'System.Threading.Thread.CurrentThread.get'
Step into: Stepping over method without symbols 'System.Threading.Thread.ManagedThreadId.get'
Step into: Stepping over method without symbols 'int.Equals'
Step into: Stepping over method without symbols 'System.Uri.ToString'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'System.DateTime.Now.get'
Step into: Stepping over method without symbols 'System.DateTime.Equals'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'System.EventArgs.EventArgs'
Step into: Stepping over method without symbols 'object.Object'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'object.ReferenceEquals'
Step into: Stepping over method without symbols 'DanielVaughan.Logging.Log..'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.ServiceModel.dll'
Step into: Stepping over property 'DanielVaughan.ChannelManagerSingleton.Instance.get'.  To step into properties, go to Tools->Options->Debugging and uncheck 'Step over properties and operators (Managed only)'.
Step into: Stepping over method without symbols 'System.Collections.Generic.Dictionary<System.Type,object>.TryGetValue'
Step into: Stepping over method without symbols 'System.ServiceModel.ChannelFactory<DanielVaughan.Logging.ClientLogging.IClogService>.ChannelFactory'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\en-US\System.ServiceModel.debug.resources.dll'
A first chance exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll
The program '[2352] iexplore.exe: Silverlight' has exited with code 0 (0x0).

Thanks in advance.

Cheers...

Karthikeyan Manickam.

Coordinator
Oct 8, 2009 at 1:47 PM

You are using Clog release assemblies, so Clog isn't going to write to your Output window.

You will either need to switch to a Debug build,

or create an Application Event Log source for Clog. Take a look at the Clog internal logger for that.

I think you probably have a problem with your WCF config. Viewing the internal logging from Clog will confirm or disprove this.

 

Oct 9, 2009 at 6:36 AM
Edited Oct 9, 2009 at 8:17 AM

Hi Daniel,

 

I've used only Debug related assemblies only. But now I'm facing the new exception, while creating the channel. the following are the error I have got while debugging.

[System.ArgumentException] = {System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)

I'm placed the "ServiceReferences.Clientconfig"  file also in my silverlight project. I'm using the same content as you given the Clog_01_08 version. Is there anything ineed to change/modify in it.

Please correct If I'm wrong.

Thanks in advance.

Cheers...

Karthikeyan Manickam.

Coordinator
Oct 9, 2009 at 8:10 AM

Are you able to set up other WCF communication from your client to your server?

If your application is not too large you can zip it up and send it to me, and I'll have a look at it.

Oct 9, 2009 at 8:23 AM

Hi Daniel,

I sent my source code to you. Please have look into it.

Thanks in advance.

Cheers...

Karthikeyan Manickam.

Coordinator
Oct 9, 2009 at 12:10 PM

I've got your project working, and sent it back to you. Be sure to update the ServiceReferences.ClientConfig file to match your url.

For some reason the default binding isn't working with your project, so it means the client config is necessary for now. I will investigate this further later.

Cheers,

Daniel

 

Oct 9, 2009 at 1:51 PM

Awesome work Daniel.

Thanks a lot you saved my day, I have started to update another stuffs in it.

If I face any other issues. will let you know.

Thanks Again,

Karthikeyan Manickam.

Oct 12, 2009 at 7:48 AM
Edited Oct 12, 2009 at 10:11 AM

Hi Daniel,

I have tried with another sample as the existing one, you gave me. But I'm facing the following errors in output window,

'iexplore.exe' (Silverlight): Loaded 'KarthikLoggerApplication', Symbols loaded.
'iexplore.exe' (Silverlight): Loaded 'DanielVaughan'
'iexplore.exe' (Silverlight): Loaded 'DanielVaughan.Logging.Silverlight'
Step into: Stepping over method without symbols 'DanielVaughan.Logging.Log.Warn'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.ServiceModel.dll'
'iexplore.exe' (Silverlight): Loaded 'ProxyBuilder'
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Diagnostics.ServiceModelSink\3.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Diagnostics.ServiceModelSink.dll'
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
Clog Debug:Initializing from config.
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
Clog Info:Added log strategy to repository. Name: Log4Net, Type: DanielVaughan.Logging.LogStrategies.Log4NetStrategy, DanielVaughan.Logging.Log4NetLogStrategy
Clog Info:Clog configuration loaded successfully.
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\en-US\System.Runtime.Serialization.debug.resources.dll'

I have corrected the web.config file as existing in the working one. I have manually changed the port no and placed the "servicereferences.clientconfig" file and place in the new project. I have tried to see log by using UDPAppender and FileAppender also. In Log4NetViewer didn't shown th log message.

Can you please let me know, If I missed anything and do correct me.

Thanks in advance.

Cheers...

Karthikeyan Manickam.

 

Oct 12, 2009 at 10:19 AM

Hi Daniel,

The following are the currently I'm getting it,

'iexplore.exe' (Silverlight): Loaded 'KarthikLoggerApplication', Symbols loaded.
'iexplore.exe' (Silverlight): Loaded 'DanielVaughan'
'iexplore.exe' (Silverlight): Loaded 'DanielVaughan.Logging.Silverlight'
Step into: Stepping over method without symbols 'DanielVaughan.Logging.Log.Debug'
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\System.ServiceModel.dll'
'iexplore.exe' (Silverlight): Loaded 'ProxyBuilder'
Step into: Stepping over method without symbols 'System.Windows.Controls.Primitives.ButtonBase.OnClick'
Step into: Stepping over method without symbols 'System.Windows.Controls.Button.OnClick'
Step into: Stepping over method without symbols 'System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp'
Step into: Stepping over method without symbols 'System.Windows.Controls.Control.OnMouseLeftButtonUp'
Step into: Stepping over method without symbols 'MS.Internal.JoltHelper.FireEvent'
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Diagnostics.ServiceModelSink\3.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Diagnostics.ServiceModelSink.dll'
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
Clog Debug:Initializing from config.
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
Clog Info:Added log strategy to repository. Name: Log4Net, Type: DanielVaughan.Logging.LogStrategies.Log4NetStrategy, DanielVaughan.Logging.Log4NetLogStrategy
Clog Info:Clog configuration loaded successfully.
'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\3.0.40818.0\en-US\System.Runtime.Serialization.debug.resources.dll'
The program '[4040] WebDev.WebServer.EXE: Managed' has exited with code 0 (0x0).
The program '[2020] iexplore.exe: Silverlight' has exited with code 0 (0x0).

Please let me know the issues.

Thanks in advance,

Cheers...

Karthikeyan Manickam.

 

 

Coordinator
Oct 12, 2009 at 11:53 AM

Are you able to log with log4net on the server?

Oct 12, 2009 at 12:19 PM

No Daniel. When I start the application I got my previous post output in the window.

Are you able to log with log4net on the server? --> Means the default message in the server as TRUE & Clog message on server.

Correct me If I'm wrong. And I didnt get those messages on my server.

Thanks,

Karthikeyan Manickam.

Coordinator
Oct 12, 2009 at 12:25 PM

Ok. So first things first. Log4Net needs to work on the server.

Look at the config. Make sure you have all references satisfied.

Oct 12, 2009 at 12:42 PM

Hi Daniel,

I tried with new application also, to log the messages from the server.  The following steps I followed,

1.Created the new application,

2. Added the .WEB references from the existing working project.

3. Added the ClogService.svc and changed the content as needed.

4. Changes made in the web.config (Service Behaviour, sections... and all).

5. Executing the project to log the messages from the server.

anything I missed please let me know. But I can't log the messages from the server.

Thanks,

Karthikeyan Manickam.

 

  

 

 

Coordinator
Oct 12, 2009 at 12:51 PM

Reference the log4net assembly and make sure you have the web.config setup the same way as the config I provided you with, and also the Global.asax.cs.

 

Oct 12, 2009 at 1:28 PM

Hi Daniel,

I DID IT.....!!!! Daniel, All because of you, Ton of thanks to you.

Actually I missed out "Global.asax" file, Now it's working as expected.

Thanks again for your continuous support and guidence towards to make me succeed.

we must PARTY :-).

Cheers...

Karthikeyan Manickam.

Oct 12, 2009 at 1:45 PM

Hi Daniel,

While logging my clent side message's I'm getting additionally "Machine Name:". I dont want to show in my logger, so how to avoid the name and why it is appeared.

The following are my logger messges available in my log file for your concern.

 

2009-10-12 18:05:16,842 [9] DEBUG TestLoggerApplication.Web.Global (null) - From Server....!
2009-10-12 18:05:17,217 [4] WARN  TestLoggerApplication.Web.Global (null) - Clog message on server.
2009-10-12 18:05:38,968 [8] DEBUG TestLoggerApplication.MainPage,/testloggerapplicationtestpage.aspx (null) - Enabled in Debug mode....!
MachineName:

Please let me know the way to avoid the same.

Thanks,

Karthikeyan Manickam.