STEAM GROUP
Archi's SC Farm Archi-ASF
STEAM GROUP
Archi's SC Farm Archi-ASF
84,147
IN-GAME
474,909
ONLINE
Founded
October 29, 2015
Language
English
All Discussions > 💬 General > Topic Details
darkstar/zx Aug 10, 2017 @ 8:25pm
Could someone help me with nlog coloring?
I am having hard time adding coloring for nlog.config for certain text's. I know the syntaxes but when i use them ASF won't even start.

If you can help me with those please add me to Steam.

I will paste my config here and you can point out the mistakes or correct it also if you wish to :]

my nlog.config

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target xsi:type="ColoredConsole" name="ColoredConsole" detectConsoleAvailable="false" layout="${date:format=yyyy-MM-dd HH\:mm\:ss}|${processname}-${processid}|${level:uppercase=true}|${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}">
<highlight-word backgroundColor="Yellow" foregroundColor="Black" ignoreCase="true" text="Cards" wholeWords="true">
<highlight-word backgroundColor="Green" foregroundColor="Black" ignoreCase="true" text="Finished" wholeWords="true">
<highlight-word backgroundColor="Blue" foregroundColor="Black" ignoreCase="true" text="trade" wholeWords="true">
<highlight-word backgroundColor="Magenta" foregroundColor="Black" ignoreCase="true" text="StartFarming" wholeWords="true">
<highlight-word backgroundColor="Red" foregroundColor="Black" ignoreCase="true" text="OnDisconnected" wholeWords="true">
<highlight-word backgroundColor="DarkYellow" foregroundColor="Black" ignoreCase="true" text="ASF" wholeWords="true"/>
</target>
<rules>
<logger name="*" minlevel="Debug" writeTo="ColoredConsole" />
</rules>
</nlog>
< >
Showing 1-11 of 11 comments
Archi Aug 12, 2017 @ 2:09pm 
You can start with http://www.xmlvalidation.com/ because your config is not even XML-valid to begin with.
darkstar/zx Aug 16, 2017 @ 6:44am 
Originally posted by Archi:
You can start with http://www.xmlvalidation.com/ because your config is not even XML-valid to begin with.

Thanks for the link!

I got this and it was validated from the link but when i put that into nlog.config ASF wont start:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">

<targets>

<!-- It colors all "Cards" instances with black txt over yellow bg -->
<target xsi:type="ColoredConsole" name="ColoredConsole" detectConsoleAvailable="false" layout="${date:format=yyyy-MM-dd HH\:mm\:ss}|${processname}-${processid}|${level:uppercase=true}|${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}">
<highlight-word backgroundColor="Yellow" foregroundColor="Black" ignoreCase="true" text="Cards" wholeWords="true"/>
</target>


<target xsi:type="EventLog" name="EventLog" layout="${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}" log="ArchiSteamFarm" source="Logger" />


<target xsi:type="File" name="File" deleteOldFileOnStartup="true" fileName="log.txt" layout="${date:format=yyyy-MM-dd HH\:mm\:ss}|${processname}-${processid}|${level:uppercase=true}|${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}" />

</targets>

<rules>
<logger name="*" minlevel="Debug" writeTo="ColoredConsole" />
<!-- <logger name="*" minlevel="Debug" writeTo="EventLog" /> -->
<logger name="*" minlevel="Debug" writeTo="File" />
</rules>
</nlog>
Archi Aug 16, 2017 @ 8:00am 
Why do you define EventLog if you're not running ASF as a service?
darkstar/zx Aug 16, 2017 @ 8:14am 
Originally posted by Archi:
Why do you define EventLog if you're not running ASF as a service?

I was only given this code from my friend i did not do this myself.
Archi Aug 16, 2017 @ 1:58pm 
Then ask your friend for help, not us.
darkstar/zx Aug 17, 2017 @ 12:49am 
Originally posted by Archi:
Then ask your friend for help, not us.

Will do, thanks for the help and the xml validator link!
darkstar/zx Aug 22, 2017 @ 5:57pm 
I cannot get hold of my "friend". Anyone could fix that so it would work? And i can give something for the troubles too if you want to :]
judgegr Aug 23, 2017 @ 5:34pm 
I've edited your initial xml, it now works. Try use it as is and then make changes on it.

<?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <targets> <target xsi:type="ColoredConsole" name="ColoredConsole" detectConsoleAvailable="false" layout="${date:format=yyyy-MM-dd HH\:mm\:ss}|${processname}-${processid}|${level:uppercase=true}|${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}"> <highlight-word backgroundColor="Yellow" foregroundColor="Black" ignoreCase="true" text="Cards" wholeWords="true"/> <highlight-word backgroundColor="Green" foregroundColor="Black" ignoreCase="true" text="Finished" wholeWords="true"/> <highlight-word backgroundColor="Blue" foregroundColor="Black" ignoreCase="true" text="trade" wholeWords="true"/> <highlight-word backgroundColor="Magenta" foregroundColor="Black" ignoreCase="true" text="StartFarming" wholeWords="true"/> <highlight-word backgroundColor="Red" foregroundColor="Black" ignoreCase="true" text="OnDisconnected" wholeWords="true"/> <highlight-word backgroundColor="DarkYellow" foregroundColor="Black" ignoreCase="true" text="ASF" wholeWords="true"/> </target> </targets> <rules> <logger name="*" minlevel="Debug" writeTo="ColoredConsole" /> </rules> </nlog>

Test output here:
http://i.imgur.com/VcKndix.png

You forgot to close with </targets>, also each '<highlight-word' must end with '/>'. Xml is verified, also my nlog.config i've sent you is verified and was working properly. Of course, defining a target as 'event' does not break nlog.config if you're not going to use it, that's why i've commented it out in the <rules> section.

TL;DR:
There were errors in closing brackets. Try using this edited code block or my nlog.config example, either nlog.config is working 100% , no matter if you're running asf as a server or not.
Last edited by judgegr; Aug 23, 2017 @ 5:42pm
darkstar/zx Aug 24, 2017 @ 7:32am 
Originally posted by judgegr:
I've edited your initial xml, it now works. Try use it as is and then make changes on it.

<?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <targets> <target xsi:type="ColoredConsole" name="ColoredConsole" detectConsoleAvailable="false" layout="${date:format=yyyy-MM-dd HH\:mm\:ss}|${processname}-${processid}|${level:uppercase=true}|${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}"> <highlight-word backgroundColor="Yellow" foregroundColor="Black" ignoreCase="true" text="Cards" wholeWords="true"/> <highlight-word backgroundColor="Green" foregroundColor="Black" ignoreCase="true" text="Finished" wholeWords="true"/> <highlight-word backgroundColor="Blue" foregroundColor="Black" ignoreCase="true" text="trade" wholeWords="true"/> <highlight-word backgroundColor="Magenta" foregroundColor="Black" ignoreCase="true" text="StartFarming" wholeWords="true"/> <highlight-word backgroundColor="Red" foregroundColor="Black" ignoreCase="true" text="OnDisconnected" wholeWords="true"/> <highlight-word backgroundColor="DarkYellow" foregroundColor="Black" ignoreCase="true" text="ASF" wholeWords="true"/> </target> </targets> <rules> <logger name="*" minlevel="Debug" writeTo="ColoredConsole" /> </rules> </nlog>

Test output here:
http://i.imgur.com/VcKndix.png

You forgot to close with </targets>, also each '<highlight-word' must end with '/>'. Xml is verified, also my nlog.config i've sent you is verified and was working properly. Of course, defining a target as 'event' does not break nlog.config if you're not going to use it, that's why i've commented it out in the <rules> section.

TL;DR:
There were errors in closing brackets. Try using this edited code block or my nlog.config example, either nlog.config is working 100% , no matter if you're running asf as a server or not.

Thanks a lot! Works fine now :]

Is there any way to color the whole line if the word is detected btw?
judgegr Aug 24, 2017 @ 1:33pm 
Originally posted by DARKKi:
Thanks a lot! Works fine now :]
Is there any way to color the whole line if the word is detected btw?

You're welcome, glad to be of help :yazdwink:
Yes it's possible to highlight a whole line, try adding this code:
<highlight-row backgroundColor="DarkGray" condition="contains('${message}','Cards')" foregroundColor="White"/>
This will highlight any row that has the word 'cards' in its message. Just be cautious that it scans only the ${message} part, if for example you need to scan for a specific bot name you might change ${message} with ${logger}.

Also, you might wanna check this wiki page[github.com] for creating more complex conditions.
Last edited by judgegr; Aug 24, 2017 @ 1:34pm
darkstar/zx Aug 24, 2017 @ 4:44pm 
Originally posted by judgegr:
Originally posted by DARKKi:
Thanks a lot! Works fine now :]
Is there any way to color the whole line if the word is detected btw?

You're welcome, glad to be of help :yazdwink:
Yes it's possible to highlight a whole line, try adding this code:
<highlight-row backgroundColor="DarkGray" condition="contains('${message}','Cards')" foregroundColor="White"/>
This will highlight any row that has the word 'cards' in its message. Just be cautious that it scans only the ${message} part, if for example you need to scan for a specific bot name you might change ${message} with ${logger}.

Also, you might wanna check this wiki page[github.com] for creating more complex conditions.

Ohh. Thanks a lot for all your help! Now it seems i can customize it like i always wanted :]
< >
Showing 1-11 of 11 comments
Per page: 1530 50

All Discussions > 💬 General > Topic Details