-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging - Allow external log4net config file #1378
Comments
If choco finds a log file next to it by the name of `log4net.config.xml` (a little bit different on purpose), it will use that file instead of the built-in configuration for log4net. Use this with caution as it could cause certain logging items to disappear when the external config does not include the necessary logging sections. It may even cause choco to error.
* stable: (GH-1379) trace tracks deep logging info (GH-1378) allow external log4net config file (GH-1377) Fix: logger code location is wrong (GH-1376) capture output to additional log file (version) 0.10.8-beta (doc) update licensed changelog (GH-1331)(doc) Pass multiple sources (maint) Remove Nuget.Core from packages.config (maint) Skip nupkg backup if changed on upgrade (maint) Update AlphaFS to 2.1.3 (maint) update NuGet.Core
Start out by placing this: https://github.com/chocolatey/choco/blob/master/src/chocolatey/infrastructure/logging/log4net.config.xml as a file next to choco in Then convert the ManagedColoredConsoleAppenders to just ConsoleAppenders. https://logging.apache.org/log4net/release/sdk/html/T_log4net_Appender_ConsoleAppender.htm Something like (not fully tested out, but it appears to work): <?xml version="1.0"?>
<!-- For colors that can be used with ManagedColoredConsoleAppender, see
http://msdn.microsoft.com/en-us/library/system.consolecolor(v=vs.110).aspx
-->
<log4net>
<appender name="NormalLoggingColoredConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="INFO" />
<param name="LevelMax" value="FATAL" />
</filter>
</appender>
<appender name="ImportantLoggingColoredConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="INFO" />
<param name="LevelMax" value="FATAL" />
</filter>
</appender>
<appender name="VerboseLoggingColoredConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="ERROR" />
<param name="LevelMax" value="FATAL" />
</filter>
</appender>
<appender name="TraceLoggingColoredConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="FATAL" />
<param name="LevelMax" value="FATAL" />
</filter>
</appender>
<root>
<level value="DEBUG" />
</root>
<logger name="Important">
<level value="DEBUG" />
<appender-ref ref="ImportantLoggingColoredConsoleAppender" />
</logger>
<logger name="Verbose">
<level value="DEBUG" />
<appender-ref ref="VerboseLoggingColoredConsoleAppender" />
</logger>
<logger name="Trace">
<level value="DEBUG" />
<appender-ref ref="TraceLoggingColoredConsoleAppender" />
</logger>
<logger name="chocolatey">
<level value="DEBUG"/>
<appender-ref ref="NormalLoggingColoredConsoleAppender" />
</logger>
<logger name="LogFileOnly">
<level value="DEBUG"/>
</logger>
</log4net> NOTE: It's best NOT to rename the appenders as Chocolatey needs to use those names internally. |
If choco finds a log file next to it by the name of
log4net.config.xml
(a little bit different on purpose), it will use that file instead of the built-in configuration for log4net. Use this with caution as it could cause certain logging items to disappear when the external config does not include the necessary logging sections. It may even cause choco to error.The text was updated successfully, but these errors were encountered: