Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi guys,
I know Umbraco uses Log4net behind the scene and the config is in log4net.config. Is it possible to log my entries to a separate file as UmbracoTraceLog is getting bloated and it's quite difficult to track my log there?
Thank you.
I've seen this post: http://blog.darren-ferguson.com/2013/02/22/log4net-logging-from-your-custom-code-in-umbraco/ And I've set up my custom logger and appender, but I still get all Umbraco logs logged to my new file.
My log4net.config looks like this:
<?xml version="1.0"?> <log4net> <root> <priority value="Info"/> <appender-ref ref="AsynchronousLog4NetAppender" /> <appender-ref ref="CustomAppender" /> </root> <!--To Change the way logging works for certain namespaces, insert a new logger like: --> <!-- <logger name="Umbraco.Core"> <level value="WARN" /> </logger>--> <logger name="My.Namespace.Web"> <level value="DEBUG" /> <appender-ref ref="CustomAppender" /> </logger> <!-- Native Umbraco appender--> <appender name="AsynchronousLog4NetAppender" type="Umbraco.Core.Logging.AsynchronousRollingFileAppender, Umbraco.Core"> <file value="App_Data\Logs\UmbracoTraceLog.txt" /> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <maximumFileSize value="5MB" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> </appender> <appender name="CustomAppender" type="Umbraco.Core.Logging.AsynchronousRollingFileAppender, Umbraco.Core"> <file value="App_Data\Logs\Custom.log.txt" /> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <maximumFileSize value="5MB" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> </appender> </log4net>
Is there anything wrong with my config?
Cheers
I figured this out,
I had to remove <appender-ref ref="CustomAppender" /> from <root>
<appender-ref ref="CustomAppender" />
<root>
change <appender name="CustomAppender" type="Umbraco.Core.Logging.AsynchronousRollingFileAppender, Umbraco.Core">
<appender name="CustomAppender" type="Umbraco.Core.Logging.AsynchronousRollingFileAppender, Umbraco.Core">
to <appender name="CustomAppender" type="log4net.Appender.FileAppender">
<appender name="CustomAppender" type="log4net.Appender.FileAppender">
Then in my code:
private static readonly ILog log = LogManager.GetLogger("MyLogger"); log.Info("Log info");
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Write logs to separate file in Umbraco 6+
Hi guys,
I know Umbraco uses Log4net behind the scene and the config is in log4net.config. Is it possible to log my entries to a separate file as UmbracoTraceLog is getting bloated and it's quite difficult to track my log there?
Thank you.
I've seen this post: http://blog.darren-ferguson.com/2013/02/22/log4net-logging-from-your-custom-code-in-umbraco/ And I've set up my custom logger and appender, but I still get all Umbraco logs logged to my new file.
My log4net.config looks like this:
Is there anything wrong with my config?
Cheers
I figured this out,
I had to remove
<appender-ref ref="CustomAppender" />
from<root>
change
<appender name="CustomAppender" type="Umbraco.Core.Logging.AsynchronousRollingFileAppender, Umbraco.Core">
to
<appender name="CustomAppender" type="log4net.Appender.FileAppender">
Then in my code:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.