Using NLog with Web Service

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

Using NLog with Web Service

Tricky-2
Whats the best way to use NLog with a webservice?
Reply | Threaded
Open this post in threaded view
|

Re: Using NLog with Web Service

Jarek Kowalski
Administrator
Can you be more specific? Using NLog with Web Services should be no different than with any other type off app.

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

Re: Using NLog with Web Service

Tricky-2
My config is like this but i dont get any output from the webservice

<configSections>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog autoReload="true">
    <targets>
        <target name="trace" type="ASPNetTrace" layout="${level:uppercase=true}    ${callsite} ${message}" />
</targets>
<rules>
     <logger name="*" minLevel="Fatal" appendTo="trace" />
</rules>
</nlog>
Reply | Threaded
Open this post in threaded view
|

Re: Using NLog with Web Service

Jarek Kowalski
Administrator
Are you sure that you have enabled ASP.NET Trace? I don't see this in the config file.

Also, when working with ASP.NET and/or webservices you might want to use "web.nlog" file (located in the same directory where web.config is located). This will prevent your application from restarting when you modify the logging config file. When using *.nlog file make <nlog /> element the root of the document.

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

Re: Using NLog with Web Service

Tricky-2
I have set trace to ture in the web.config and this is my config.nlog file

<nlog>
<targets>
<target name="file" type="File" filename="${basedir}/logs/logfile.txt" layout="${longdate} ${level:uppercase=true} ${logger} ${aspnet-session:variable=UserName} ${threadid} ${callsite} ${message}" />
<target name="trace" type="ASPNetTrace" layout="${level:uppercase=true} ${callsite} ${message}" />
    </targets>

    <rules>
        <logger name="*" minLevel="Info" appendTo="trace" />
        <logger name="*" minLevel="Debug" appendTo="file" />
    </rules>
</nlog>

But i'm still not getting any output, is there something i'm missing?

Reply | Threaded
Open this post in threaded view
|

Re: Using NLog with Web Service

Jarek Kowalski
Administrator
The file should be named "web.nlog" not "config.nlog"

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

Re: Using NLog with Web Service

Tricky-2
I have change it to web.nlog, but i'm still not getting any file written or trace log.
Reply | Threaded
Open this post in threaded view
|

Re: Using NLog with Web Service

Jarek Kowalski
Administrator
1. Can you verify that this isn't a permission problem?

2. Have you granted the "Network Service" (on Win2003) or "ASPNET" (on Windows XP) account write access to the specified directory?

3. What version of NLog are you using?

4. What is the version of .NET ?

5. Can you use sysinternals.com FILEMON tool to verify that any writes are attempted?

6. Can you upgrade to the latest nightly build of NLog and check again?

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

Re: Using NLog with Web Service

Tricky-2
Got it to work it was a permission problem on are network.