log from clients side esri storymaps

3109
6
12-24-2015 03:49 AM
roialgavish
New Contributor III

Hello,

I am using the map tour template, in a dynamic environment. In that I mean that I send a url parameter to the app and then going to a different json (to use as web map). I want to add a script to the index file that will enable me to write a text file on my server that will log all of the entries and to where they went (by the url parameter).

I am only a client side JavaScript developer and after some time searching the web I couldn't find a good solution.  Is there any ideas?

Thank you all,

Roi.

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Roi,

    This is not possible with client side technology like JavaScript. You would have to use a server side tech like asp.net or some web service. You can always do some Google search for a tutorial as what you are wanting to do is relatively side a beginner should have have any issue. A simple Google Search like "asp.net write log to text file" produces lots of results and you can get Visual Studio Express for free.

0 Kudos
JordanBaumgardner
Occasional Contributor III

I have had good luck with JSNlog - Logging JavaScript errors to your server side log - JSNLog

It is a client (JS) side logging framwork/Lib that will "beam" your logs back to the server. It has several backends that work with it and all are very easily configured.

roialgavish
New Contributor III

Jordan Hello,

I tried using jsnlog only with the js option, and I failed.

I put the jsnlog.js and a jsnlog.logger in my app folder (as attached in the picture).AppFolder.JPG

I haven't done step two in the installation guide which is - Format of the log messages  Because I didn’t understand what to write there I added this line to my index.html - JL().fatal("log message");

What I get in the cosole is: RiskApp/jsnlog.logger 405 (Method Not Allowed).

If you can help me it will be grate.

thanks, Roi.

0 Kudos
JordanBaumgardner
Occasional Contributor III

I'm a C# kinda guy and I'm using ASP.net and a Web.config

I needed to tell IIS that it is ok to use the other HTTP Verbs [ Post and Delete ] like this:

        <add name="Access-Control-Allow-Credentials" value="true" />

        <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />

        <add name="Access-Control-Allow-Headers"

             value="X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-Requested-With" />

More Context:

  <system.webServer>

    <handlers>

      <add name="LoggerHandler" verb="*" path="*.logger" type="JSNLog.LoggerHandler, JSNLog" resourceType="Unspecified"

           preCondition="integratedMode" />

      <add name="LoggerHandler-Classic" path="*.logger" verb="*" modules="IsapiModule"

           scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified"

           preCondition="classicMode" />

    </handlers>

    <httpProtocol>

      <customHeaders>

        <add name="Access-Control-Allow-Credentials" value="true" />

        <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />

        <add name="Access-Control-Allow-Headers"

             value="X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-Requested-With" />

      </customHeaders>

    </httpProtocol>

  </system.webServer>

  <jsnlog productionLibraryPath="~/Scripts/libraries/jsnlog.js" serverSideLevel="INFO"

          serverSideMessageFormat="CLIENTLOG, %level, %logger, %jsonmessage, %userHostAddress, %url" />

  <common>

    <logging>

      <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net1211">

        <arg key="configType" value="INLINE" />

      </factoryAdapter>

    </logging>

  </common>

I can't tell from your post what back end you chose, but I would wager there is a "Server Side" setup section of JSNlog setup that you need to go back over. I believe your problem lies there. Its trying to send the log message back to the server and is being blocked because its using the HTTP verb "Put" and that is being blocked by your web server. You need to let it know, Put is Ok. The specifics will be in the install section of the back end you chose (php, java, C#, ect)

0 Kudos
roialgavish
New Contributor III

Hello,

In order to use the .net installation of the jsnlog I need to imbed the storymap app in a aspx project I do not want to do that. That Is way it tried to use the "only JS" part of the jsnlog I wasn’t successful because of some IIS problems.

If there is more ideas about how to log some data only with JS it would be great.

Thank allot Roi.

0 Kudos
JordanBaumgardner
Occasional Contributor III

Well, you need to use some sort of back end to "catch" the log message. The client will post it back to A server. It doesn't have to be that particular installation, it could be anywhere.

But at some point you need to put some server code up somewhere.

I don't think you need to change templates however. You would need to modify the current template (ie add the js startup code) and add the proper init stuff to your web.config.

The simplest solution might be to just have a separate site to just catch the logs. You could then use whatever back end was simplest for you.

You will still need to modify the template to add your jsnlog init code and link in the lib.

0 Kudos