Archive of ‘Logging’ category

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”/>
</logger>

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