Sitecore 7.5
The text file logging is working fine. But, I would like the logging to go to a SQL Server database so that I can search the data with T-SQL.
How would I do that?
I imagine it would be a change to the web.config file inside the <log4net>
block. And, also an additional connection string.
<log4net>
<!-- LOGGING SETTINGS
The file element defines the location of the log files. This location must
be the same as the setting in LogFolder. The file element is a relative or
absolute path that always uses slashes (/) as separators. A valid file
element for a relative path would be:
<file value="/data/logs/log.{date}.{processid}.txt"/>
A valid element for an absolute path would be:
<file value="C:/inetpub/wwwroot/data/logs/log.{date}.{processid}.txt"/>
The macros supported are:
{date}: Replaced with the current date (in the format yyyyMMdd)
{time}: Replaced with the current time (in the format HHmmss)
{processid}: Replaced with the current Windows process id
For further information refer to the Log4Net documentation.
-->
<appender name="LogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/log.{date}.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
</layout>
<encoding value="utf-8" />
</appender>
<appender name="WebDAVLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/WebDAV.log.{date}.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
</layout>
<encoding value="utf-8" />
</appender>
<appender name="SearchLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/Search.log.{date}.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
</layout>
<encoding value="utf-8" />
</appender>
<appender name="CrawlingLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/Crawling.log.{date}.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
</layout>
<encoding value="utf-8" />
</appender>
<appender name="PublishingLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/Publishing.log.{date}.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
</layout>
<encoding value="utf-8" />
</appender>
<appender name="NHibernateLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/NHibernate.log.{date}.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
</layout>
<encoding value="utf-8" />
</appender>
<root>
<priority value="INFO" />
<appender-ref ref="LogFileAppender" />
</root>
<logger name="Sitecore.Diagnostics.WebDAV" additivity="false">
<level value="INFO" />
<appender-ref ref="WebDAVLogFileAppender" />
</logger>
<logger name="Sitecore.Diagnostics.Search" additivity="false">
<level value="INFO" />
<appender-ref ref="SearchLogFileAppender" />
</logger>
<logger name="Sitecore.Diagnostics.Crawling" additivity="false">
<level value="INFO" />
<appender-ref ref="CrawlingLogFileAppender" />
</logger>
<logger name="Sitecore.Diagnostics.Publishing" additivity="false">
<level value="INFO" />
<appender-ref ref="PublishingLogFileAppender" />
</logger>
<logger name="NHibernate" additivity="false">
<level value="WARN" />
<appender-ref ref="NHibernateLogFileAppender" />
</logger>
<logger name="NHibernate.SQL" additivity="false">
<level value="WARN" />
<appender-ref ref="NHibernateLogFileAppender" />
</logger>
</log4net>