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.
${basedir} — Directory where the application runs, aka. AppDomain.BaseDirectory.
${basedir}
— Directory where the application runs, aka. AppDomain.BaseDirectory
I think, you will find this manual page helpful.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With