mikrotik log code example

Example: mikrotik address list log into file

{
	:local listName "Server"; #change this
	:local fileName "exported.rsc"; #change this
	:local buffer;

	:global filteredList [/ip firewall address-list print as-value where list=$listName && dynamic=no];
	:foreach i in=$filteredList do={
		:set $buffer ($buffer."add list=".$listName." address=".$i->"address"."; ");
	};
	/file print file=$fileName where name="";
	:delay 1s;
	:set $buffer ("/ip firewall address-list; ".$buffer);
	/file set $fileName contents=$buffer;
}