Logging to a Database with Log4Net

If you need to log to a database instead of a text file, you can use Log4Net to do it by just changing some config: http://sitecoreblog.alexshyba.com/2010/07/sitecore-logging-write-it-to-sql.html

If you want to only log a small number of things to the database (but still log everything else to the existing log), then instead of adding the sql adonet appender to the main root logger in the config, create a new logger node and add the sql ado appender to that. Eg:

<logger name=”PublishLog” additivity=”false”>
<level value=”INFO”/>
<appender-ref ref=”ADONetAppender_PublishedItems”/>

Then when logging, explicitly use this logger using the Sitecore Logger Factory. Eg: “Sitecore.Diagnostics.LoggerFactory.GetLogger(“PublishLog”)”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">