Page 1 of 1

How do I enable logging?

Posted: Thu 13 Nov, 2025 6:29 pm
by Campbell
Maxim Money uses Nlog for logging, which allows logs to be redirected to pretty much any format you like.

To create a basic text file log, create a file called nlog.config in the same folder as the MaximMoney.exe file, and paste in these contents:

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<!-- XSD manual extracted from package NLog.Schema: https://www.nuget.org/packages/NLog.Schema-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
      autoReload="true">

	<!-- the targets to write to -->
	<targets>
		<!-- write logs to file -->
		<target xsi:type="File" name="logfile" fileName="C:\Users\Campbell.WILD\AppData\Local\MaximMoney\maxim.log"
			layout="${longdate}  [${level}  ${event-properties:item=Category}]:  ${message}  ${exception:format=tostring}" />
	</targets>

	<!-- rules to map from logger name to target -->
	<rules>	  	  
		<logger name="*" minlevel="Info" writeTo="logfile" />			
	</rules>

</nlog>
This will output all Info level logging to the log file. Obviously, set fileName to a relevant path on your filesystem.

Please note, Maxim Money needs to have sufficient permissions to write to the folder you would like to output the log file to, otherwise it will be unable to create the file, so it's normally best to set this to your Documents or a Temp folder.

If you wish to output more detail in a particular area, you can add a section like so within the <rules></rules> section:

Code: Select all

	<logger name="*" minlevel="Debug" maxLevel="Debug" writeTo="logfile" >
		<filters defaultAction="Ignore">
			<when condition="'${event-properties:item=Category}' == 'Pricing'" action="Log" />			  
		 </filters>
	</logger>
The levels you can add are: Fatal, Error, Warn, Info, Debug and Trace.
The Categories you can add are: Data, General, IO, Licensing, Online, Pricing and Transactions.

NB. You may get duplicate logging if you configure the additional section(s) to overlap the maxLevel with the general logging output.