Closed RobThree closed 8 years ago
Damian and I took the decision that ColouredConsoleLogger doesn't belong in LibLog, as application/library/framework devs can just copy and paste the code from a Gist or put it into their own code. I'll need to pull ColouredConsoleLogger into NEventSocket.Logging and then update the package.
Those were exactly my findings. I added the ColouredConsoleLogger
as a separate class in the Logging namespace and then tried updating the rest of LibLog but, apparently, it has changed quite a bit so it wasn't just a simple "update with the newest code"; it needs a bit more work than that.
Again: I'm willing to take another stab at it when I have the time and submit a PR but that could take a while. I opened an issue to 'create awareness' (and, granted, in the hope someone would be able to have a look as well). But to be clear: I'm not as much interested in the ColouredConsoleLogger
as to just being able to silence the logging from NEventSocket
(or at least silence it a bit).
What logging lib are you using?
I mostly use NLog at the moment and use filters to set the log level for noisy libraries, eg, EventStore and EasyNetQ log quite a lot of info that I don't need to see in the console:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" throwExceptions="true" internalLogLevel="Info">
<targets>
<!-- Log in a separate thread, possibly queueing up to
5000 messages. When the queue overflows, discard any
extra messages-->
<target name="file" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
<target xsi:type="File" name="files" fileName="${basedir}/logs/log.current.log"
layout="${longdate}|${callsite}|${level}|${message}|${exception:format=Message,StackTrace}|${stacktrace}"
archiveFileName="${basedir}/logs/archives/log.${date:format=yyyy-MM-dd}.{#}.log " archiveEvery="Day"
archiveNumbering="Rolling" maxArchiveFiles="7" concurrentWrites="true" keepFileOpen="false" />
</target>
<target name="console" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
<target name="console" xsi:type="ColoredConsole"
layout="${level} [${threadid}] ${logger} ${message} ${exception:format=Message,StackTrace}">
<highlight-row condition="Level==LogLevel.Fatal" foregroundColor="Red" />
<highlight-row condition="Level==LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="Level==LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="Level==LogLevel.Info" foregroundColor="DarkCyan" />
<highlight-row condition="Level==LogLevel.Debug" foregroundColor="DarkGreen" />
</target>
</target>
</targets>
<rules>
<logger name="EventStore.*" minLevel="Error" writeTo="console" final="true" />
<logger name="EasyNetQ*" minLevel="Warn" writeTo="console" final="true" />
<logger name="*" minLevel="Debug" writeTo="console" />
<logger name="*" minLevel="Info" writeTo="file" />
</rules>
</nlog>
I use NLog as well. I hadn't thought of using <rules>
for more selectively logging NEventSocket messages and, quite honestly, I don't understand why I didn't come up with that in the first place. Jeez... Thanks for making me feel stupid :stuck_out_tongue_winking_eye: (/jk). I'll resort to using the rules. Consider this issue non-existing. My apologies.
Edit: So this is what I, basically, ended up with:
<rules>
<logger name="NEventSocket.*" minlevel="Trace" maxlevel="Info" final="true" />
<logger name="*" minlevel="Trace" writeTo="someTarget" />
</rules>
Let's leave this open as LibLog does need updating at some point, glad I could help. :)
A lot of FreeSwitch/ESL work involves trial and error, so sometimes it helps to have a lot of info logged in the console when you are prototyping, but you would definitely want to dial it down in production.
Hi!
I would kindly like to request you update LibLog so that I can silcence logging from NEventSocket.
I took a stab at it myself but the ColouredConsoleLogger has since been removed; I tried adding it back in but all sorts of other problems arose and, unfortunately, I don't have the time right now (not that I expect you to fix this anytime soon!). I will try again later and submit a PR if I get around to it.