Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[Submissions] Extending the functionality of any Habbo Emulator
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Seriosk" data-source="post: 401664" data-attributes="member: 72056"><p>I hope you like this, I recoded it in NLog library. Log4net isn't that great, as shown on these benchmarks below</p><p><img src="https://www.loggly.com/wp-content/uploads/2016/01/netchart.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>Anyway, here is the code for the new logging..</p><p></p><p>NLog.config?</p><p>[CODE]</p><p><?xml version="1.0" encoding="utf-8" ?></p><p><nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"</p><p> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></p><p></p><p> <targets></p><p> <target name="coloredConsole" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false"</p><p> layout=" ${date:format=HH\:mm\:ss} - ${message}" ></p><p> <highlight-row condition="level == LogLevel.Trace" foregroundColor="White" /></p><p> <highlight-row condition="level == LogLevel.Debug" foregroundColor="Cyan" /></p><p> <highlight-row condition="level == LogLevel.Info" foregroundColor="Green" /></p><p> <highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" /></p><p> <highlight-row condition="level == LogLevel.Error" foregroundColor="Red" /></p><p> <highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" /></p><p> </target></p><p></p><p> <target name="traceFile" xsi:type="File"</p><p> layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}"</p><p> fileName="${basedir}/assets/logging/trace.log" keepFileOpen="false" encoding="iso-8859-2" /></p><p> </p><p> <target name="debugFile" xsi:type="File"</p><p> layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}"</p><p> fileName="${basedir}/assets/logging/debug.log" keepFileOpen="false" encoding="iso-8859-2" /></p><p> </p><p> <target name="infoFile" xsi:type="File"</p><p> layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}"</p><p> fileName="${basedir}/assets/logging/info.log" keepFileOpen="false" encoding="iso-8859-2" /></p><p> </p><p> <target name="warnFile" xsi:type="File"</p><p> layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}"</p><p> fileName="${basedir}/assets/logging/warn.log" keepFileOpen="false" encoding="iso-8859-2" /></p><p> </p><p> <target name="errorFile" xsi:type="File"</p><p> layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}"</p><p> fileName="${basedir}/assets/logging/error.log" keepFileOpen="false" encoding="iso-8859-2" /></p><p> </p><p> <target name="fatalFile" xsi:type="File"</p><p> layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}"</p><p> fileName="${basedir}/assets/logging/fatal.log" keepFileOpen="false" encoding="iso-8859-2" /></p><p> </targets></p><p></p><p> <rules></p><p> <logger name="*" minlevel="Trace" writeTo="coloredConsole" /></p><p> <logger name="*" minlevel="Trace" maxLevel="Trace" writeTo="traceFile" /></p><p> <logger name="*" minlevel="Debug" maxLevel="Debug" writeTo="debugFile" /></p><p> <logger name="*" minlevel="Info" maxLevel="Info" writeTo="infoFile" /></p><p> <logger name="*" minlevel="Warn" maxLevel="Warn" writeTo="warnFile" /></p><p> <logger name="*" minlevel="Error" maxLevel="Error" writeTo="errorFile" /></p><p> <logger name="*" minlevel="Fatal" maxLevel="Fatal" writeTo="fatalFile" /></p><p> </rules></p><p></nlog></p><p>[/CODE]</p><p></p><p>In your Program.cs, you may want to change that path to where ever you save the nlog.config..</p><p>[CODE]</p><p>LogManager.Configuration = new XmlLoggingConfiguration("/nlog/nlog.config");</p><p>[/CODE]</p><p></p><p>How to use?, well, each class you want to use it in, simply put the code below:</p><p>[CODE]</p><p>private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();</p><p>[/CODE]</p><p></p><p>In Plus, it's something like this:</p><p>[CODE]</p><p>private static readonly ILog log = LogManager.GetLogger("Plus.SomeNamespaceIdek");</p><p>[/CODE]</p><p></p><p>Then, log away?, you may want to change the Log configuration to your liking <img src="/styles/default/xenforo/smilies/emojione/tongue.png" class="smilie" loading="lazy" alt=":p" title="Stick Out Tongue :p" data-shortname=":p" /></p><p></p><p>Usage:</p><p>[CODE]</p><p>Logger.Debug("Debug test...");</p><p>Logger.Error("Error test...");</p><p>Logger.Fatal("Fatal test...");</p><p>Logger.Info("Info test...");</p><p>Logger.Trace("Trace test...");</p><p>Logger.Warn("Warn test...");</p><p>[/CODE]</p><p></p><p>Last step you'll need to install the Nuget package for NLog from Nuget Package Manager.</p></blockquote><p></p>
[QUOTE="Seriosk, post: 401664, member: 72056"] I hope you like this, I recoded it in NLog library. Log4net isn't that great, as shown on these benchmarks below [IMG]https://www.loggly.com/wp-content/uploads/2016/01/netchart.png[/IMG] Anyway, here is the code for the new logging.. NLog.config? [CODE] <?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 name="coloredConsole" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false" layout=" ${date:format=HH\:mm\:ss} - ${message}" > <highlight-row condition="level == LogLevel.Trace" foregroundColor="White" /> <highlight-row condition="level == LogLevel.Debug" foregroundColor="Cyan" /> <highlight-row condition="level == LogLevel.Info" foregroundColor="Green" /> <highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" /> <highlight-row condition="level == LogLevel.Error" foregroundColor="Red" /> <highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" /> </target> <target name="traceFile" xsi:type="File" layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}" fileName="${basedir}/assets/logging/trace.log" keepFileOpen="false" encoding="iso-8859-2" /> <target name="debugFile" xsi:type="File" layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}" fileName="${basedir}/assets/logging/debug.log" keepFileOpen="false" encoding="iso-8859-2" /> <target name="infoFile" xsi:type="File" layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}" fileName="${basedir}/assets/logging/info.log" keepFileOpen="false" encoding="iso-8859-2" /> <target name="warnFile" xsi:type="File" layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}" fileName="${basedir}/assets/logging/warn.log" keepFileOpen="false" encoding="iso-8859-2" /> <target name="errorFile" xsi:type="File" layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}" fileName="${basedir}/assets/logging/error.log" keepFileOpen="false" encoding="iso-8859-2" /> <target name="fatalFile" xsi:type="File" layout="[${pad:padding=5:inner=${level:uppercase=true}}] occurred at [${longdate}] in [${logger}]: ${message}" fileName="${basedir}/assets/logging/fatal.log" keepFileOpen="false" encoding="iso-8859-2" /> </targets> <rules> <logger name="*" minlevel="Trace" writeTo="coloredConsole" /> <logger name="*" minlevel="Trace" maxLevel="Trace" writeTo="traceFile" /> <logger name="*" minlevel="Debug" maxLevel="Debug" writeTo="debugFile" /> <logger name="*" minlevel="Info" maxLevel="Info" writeTo="infoFile" /> <logger name="*" minlevel="Warn" maxLevel="Warn" writeTo="warnFile" /> <logger name="*" minlevel="Error" maxLevel="Error" writeTo="errorFile" /> <logger name="*" minlevel="Fatal" maxLevel="Fatal" writeTo="fatalFile" /> </rules> </nlog> [/CODE] In your Program.cs, you may want to change that path to where ever you save the nlog.config.. [CODE] LogManager.Configuration = new XmlLoggingConfiguration("/nlog/nlog.config"); [/CODE] How to use?, well, each class you want to use it in, simply put the code below: [CODE] private static readonly ILogger Logger = LogManager.GetCurrentClassLogger(); [/CODE] In Plus, it's something like this: [CODE] private static readonly ILog log = LogManager.GetLogger("Plus.SomeNamespaceIdek"); [/CODE] Then, log away?, you may want to change the Log configuration to your liking :p Usage: [CODE] Logger.Debug("Debug test..."); Logger.Error("Error test..."); Logger.Fatal("Fatal test..."); Logger.Info("Info test..."); Logger.Trace("Trace test..."); Logger.Warn("Warn test..."); [/CODE] Last step you'll need to install the Nuget package for NLog from Nuget Package Manager. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[Submissions] Extending the functionality of any Habbo Emulator
Top