Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is ${basedir} located, using NLog?

Unless I'm totally missing it, I'm under the impression that the NLog documentation uses ${basedir} in its examples, without explaining what its location is supposed to be.

Where can I find information that lists all possible options with a meaningful description?

I have this configuration defined:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true">   <targets>     <target name="file" xsi:type="File"                 layout="${longdate} ${logger} ${message}"                 fileName="${basedir}/logs/${shortdate}.txt"                 keepFileOpen="false"                 encoding="iso-8859-2" />   </targets>   <rules>     <logger name="*" minlevel="Debug" writeTo="file" />   </rules> </nlog> 

It works as far as I can tell, but I haven't got a clue where it logs anything at.

like image 410
Spikee Avatar asked Feb 05 '16 12:02

Spikee


People also ask

What is Basedir in NLog?

${basedir} — Directory where the application runs, aka. AppDomain.BaseDirectory.


2 Answers

${basedir} — Directory where the application runs, aka. AppDomain.BaseDirectory

I think, you will find this manual page helpful.

like image 100
galakt Avatar answered Sep 19 '22 07:09

galakt


Based on already provided answers and comments, the answer can be summed up for .NET application:

AppDomain.CurrentDomain.BaseDirectory 

For Console or Windows Forms application, this directory is bin/debug while within Visual Studio. If application is deployed, the path will most probably be the executable path.

For Web applications (ASP.NET) this will be the Web application root directory.

Not seeing any files may be triggered by several causes that include: NLog configuration errors and not being able to write the target file. To expose these errors make sure that NLog.config (or Nlog configuration embedded within web.config or app.config) specifies an internal log file to output such errors:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       internalLogFile="C:\NLogError\NLog.log">  <!-- targets and rules come here -->  </nlog> 
like image 26
Alexei - check Codidact Avatar answered Sep 18 '22 07:09

Alexei - check Codidact