Any Extended Profile for Configuration flie in Windows phone 7.1 ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Any Extended Profile for Configuration flie in Windows phone 7.1 ?

Nickshi
Hi all:

I used NLog on my Windows phone 7.1( targets 'Silverlight,Version=v4.0,Profile=WindowsPhone71') APP.
Now the questions is :

the NLog can'g parase the configuration file(NLog.config), and then i make a target to store a file
in IsolatedStorage, the code:

///////////////////////////////////////////
using System;
using NLog;
using NLog.Targets;
using System.IO.IsolatedStorage;
using System.IO;
using System.Diagnostics;

namespace NLogIsolatedStorage
{
    [Target("IsolatedStorage")]
    public sealed class IsolatedStorageTarget : TargetWithLayout
    {

        public IsolatedStorageTarget()
        {
        }
        protected override void Write(LogEventInfo logEvent)
        {
            try
            {
                using (IsolatedStorageFile store =
                IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (Stream stream = new IsolatedStorageFileStream
                    ("NLog.txt", FileMode.Append, FileAccess.Write, store))
                    {
                        StreamWriter writer = new StreamWriter(stream);
                        writer.WriteLine(this.Layout.Render(logEvent));
                        writer.Close();
                    }

                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
    }
}


////////////////////////////////////////////////////////////////

And then, add a NLog.config

///////////////////////////////////////////////////////////////

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <extensions>
    <add assembly="NLogIsolatedStorage"/>
  </extensions>

  <targets>
    <target name="Log" xsi:type="IsolatedStorage" />
  </targets>

  <rules>
    <logger name="*" minlevel="Info" writeTo="Log" />
  </rules>
</nlog>


/////////////////////////////////////////////////////////

as result, it's dosen't work!  the exception is :

Exception occurred when loading configuration from NLog.config


Anyone can give some useful advises  ?


Regards
Reply | Threaded
Open this post in threaded view
|

Re: Any Extended Profile for Configuration flie in Windows phone 7.1 ?

Jarek Kowalski
Administrator
Try <add type="NLogIsolatedStorage.IsolatedStorageTarget, NLogIsolatedStorage" /> instead.

Silverlight does not support dynamically loading undeclared assemblies, but it happily supports fully qualified type names.

Jarek
NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: Any Extended Profile for Configuration flie in Windows phone 7.1 ?

Nickshi
Jarek, thank you for you advise.

The final configuration should look like this:

///////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <extensions>
    <add assembly="NLogIsolatedStorage"/>
  </extensions>

  <targets>
    <target name="Log" xsi:type="IsolatedStorage" />
  </targets>

  <rules>
    <logger name="*" minlevel="Info" writeTo="Log" />
  </rules>
</nlog>

/////////////////////////////////////////////////////////////////////

 " Try <add type="NLogIsolatedStorage.IsolatedStorageTarget, NLogIsolatedStorage" /> instead. "

So, instead which line or put your code in where ?


Happy day!


regards
Reply | Threaded
Open this post in threaded view
|

Re: Any Extended Profile for Configuration flie in Windows phone 7.1 ?

Nickshi
I got, Thanks !
Reply | Threaded
Open this post in threaded view
|

Re: Any Extended Profile for Configuration flie in Windows phone 7.1 ?

Nickshi
The results as before :(

"NLogConfigurationException was unhandle ,
 Exception occurred when loading configuration from NLog.config "

I should find another way .