ASP .NET 2.0

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

ASP .NET 2.0

jvela
Hello I'm trying to use Nlog with ASP.net 2.0 but it doesn't work. Somebody try it?

Regards

Reply | Threaded
Open this post in threaded view
|

Re: ASP .NET 2.0

Jarek Kowalski
Administrator
Please send your configuration information or we'll be unable to help you.

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

Re: ASP .NET 2.0

jvela
<nlog>
<extensions>
<add assembly="App_Code"/>
</extensions>
<targets>
<target name="fileAll" type="File" filename="C:/Server/${date:format=yyyy-MM-dd}_log.txt" layout="${longdate} ${level:uppercase=true} ${logger} ${aspnet-session:variable=UserName} ${threadid} ${callsite} ${message}"/>
</targets>
<rules>
<logger name="*" levels="Info,Error" writeTo="fileAll"/>
</rules>
</nlog>

Reply | Threaded
Open this post in threaded view
|

Re: ASP .NET 2.0

Jarek Kowalski
Administrator
Try adding

<nlog throwExceptions="true">
...
</nlog>

and it will alert you on any problems.

I suspect this might be a permission problem. If it indeed is, you need to grant the ASPNET or "Network Service" user the right to write to C:/Server

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

Re: ASP .NET 2.0

jvela
It doesn't throw any alert, I think the problem could be here      
<extensions>
<add assembly="App_Code"/>
</extensions>

but I don't know why.

Thanks and regards
Reply | Threaded
Open this post in threaded view
|

Re: ASP .NET 2.0

Jarek Kowalski
Administrator
Just remove it. Since you're only logging to a file, this shouldn't be a problem.

Can you post your logging code (C#) ?

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

Re: ASP .NET 2.0

jvela
 private static NLog.Logger logg = NLog.LogManager.GetLogger("a");

  protected void Page_Load(object sender, EventArgs e)
    {
        logg.Info("Info logger");
          }
Reply | Threaded
Open this post in threaded view
|

Re: ASP .NET 2.0

Jarek Kowalski
Administrator
Strange, should be working fine.

Can you try the simplest case, perhaps there's a typo which I cannot see:

Make sure to put this in "web.nlog" file next to your "web.config" or add it as a section inside Web.config (see the docs).

<nlog throwExceptions="true">

<targets>
   <target name="file" type="File" filename="c:/server/log.txt" />
</targets>

<rules>
   <logger name="*" minlevel="Debug" writeTo="file" />
</rules>

</nlog>

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

Re: ASP .NET 2.0

jvela
I try it, and It doesn't work, I try this

<nlog>
<targets>
<target name="fileAll"  type="Console" />         
</targets>
<rules>
<logger name="*" levels="Debug, Info" writeTo="fileAll"/>
</rules>
</nlog>

but It doesn't work
Reply | Threaded
Open this post in threaded view
|

Re: ASP .NET 2.0

Jarek Kowalski
Administrator
Why can't you try the example provided by me? Your doesn't have a chance of working since Console doesn't exist under IIS, so you wouldn't be seeing any output.

Can you zip your website and NLog config file preserving their structure and send them to me? I believe we have some file naming problem...

Jarek
NLog Blog