So here is a detailed guide on how to configure wowza to log into Microsoft SQL Server 2005 or later. I have tested it with SQL Server 2008 R2 November CTP, but it should work with other versions as well.
There are some prerequisities what you must check before begin:
As a first step download the latest JDBC driver from Microsoft: http://www.microsoft.com/downloads/details.aspx?FamilyID=f914793a-6fb4-475f-9537-b8fcb776befd&displaylang=en
After unzipping it into a directory, copy sqljdbc4.jar into the lib folder of your Wowza Media Server installation.
Now we’ve to create a database and a user for this database with read/write rights.
Please make sure that you will change username or at least the default password for production environment.
Start up SQL Server Management Studio and execute the following database script:
CREATE DATABASE WowzaLog
GO
BEGIN TRAN
GO
USE WowzaLog
GO
CREATE TABLE dbo.AccessLog
(
Id int NOT NULL IDENTITY (1, 1),
[Date] NVARCHAR(100) NULL,
[Time] NVARCHAR(100) NULL,
TZ NVARCHAR(100) NULL,
XEVENT NVARCHAR(20) NULL,
XCATEGORY NVARCHAR(20) NULL,
XSEVERITY NVARCHAR(100) NULL,
XSTATUS NVARCHAR(100) NULL,
XCTX NVARCHAR(100) NULL,
XCOMMENT NVARCHAR(255) NULL,
XVHOST NVARCHAR(100) NULL,
XAPP NVARCHAR(100) NULL,
XAPPINST NVARCHAR(100) NULL,
XDURATION NVARCHAR(100) NULL,
SIP NVARCHAR(100) NULL,
SPORT NVARCHAR(100) NULL,
SURI NVARCHAR(255) NULL,
CIP NVARCHAR(100) NULL,
CPROTO NVARCHAR(100) NULL,
CREFERRER NVARCHAR(255) NULL,
CUSERAGENT NVARCHAR(100) NULL,
CCLIENTID NVARCHAR(25) NULL,
CSBYTES NVARCHAR(20) NULL,
SCBYTES NVARCHAR(20) NULL,
XSTREAMID NVARCHAR(20) NULL,
XSPOS NVARCHAR(20) NULL,
CSSTREAMBYTES NVARCHAR(20) NULL,
SCSTREAMBYTES NVARCHAR(20) NULL,
XSNAME NVARCHAR(100) NULL,
XSNAMEQUERY NVARCHAR(100) NULL,
XFILENAME NVARCHAR(100) NULL,
XFILEEXT NVARCHAR(100) NULL,
XFILESIZE NVARCHAR(100) NULL,
XFILELENGTH NVARCHAR(100) NULL,
XSURI NVARCHAR(255) NULL,
XSURISTEM NVARCHAR(255) NULL,
XSURIQUERY NVARCHAR(255) NULL,
CSURISTEM NVARCHAR(255) NULL,
CSURIQUERY NVARCHAR(255) NULL
) ON [PRIMARY]
GO
ALTER TABLE dbo.AccessLog ADD CONSTRAINT
PK_AccessLog PRIMARY KEY CLUSTERED
(
Id
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.AccessLog SET (LOCK_ESCALATION = TABLE)
GO
CREATE LOGIN [WowzaLogger] WITH PASSWORD=N'P@ssw0rd', DEFAULT_DATABASE=[WowzaLog], CHECK_EXPIRATION=ON, CHECK_POLICY=ON
GO
CREATE USER [WowzaLogger] FOR LOGIN [WowzaLogger]
GO
EXEC sp_addrolemember N'db_datareader', N'WowzaLogger'
GO
EXEC sp_addrolemember N'db_datawriter', N'WowzaLogger'
GO
COMMIT
GO
If everything went OK, then you’ve a database named WowzaLog in you SQL Server and an AccessLog table in it.
Open /conf/log4j.properties. In the first line, add a new root category “SQ”:
log4j.rootCategory=INFO, stdout, serverAccess, serverError, SQ
In the same file, copy in the following appender:
# SQL Server appender
log4j.appender.SQ=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.SQ.Driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
log4j.appender.SQ.URL=jdbc:sqlserver://localhost;databaseName=WowzaLog
log4j.appender.SQ.user=WowzaLogger
log4j.appender.SQ.password=P@ssw0rd
log4j.appender.SQ.layout=com.wowza.wms.logging.ECLFPatternLayout
log4j.appender.SQ.layout.OutputHeader=false
log4j.appender.SQ.sql=INSERT INTO accesslog (date, time, tz, xevent, xcategory, xseverity,xstatus,xctx,xcomment,xvhost,xapp,xappinst,xduration,sip,sport,suri,cip,cproto,creferrer,cuseragent,cclientid,csbytes,scbytes,xstreamid, xspos,csstreambytes,scstreambytes,xsname,xsnamequery,xfilename,xfileext,xfilesize,xfilelength,xsuri,xsuristem,xsuriquery,csuristem,csuriquery) VALUES ('%X{date}', '%X{time}', '%X{tz}', '%X{x-event}', '%X{x-category}', '%X{x-severity}', '%X{x-status}', '%X{x-ctx}', '%X{x-comment}', '%X{x-vhost}', '%X{x-app}', '%X{x-appinst}', '%X{x-duration}', '%X{s-ip}', '%X{sport}', '%X{s-uri}', '%X{c-ip}', '%X{c-proto}', '%X{c-referrer}', '%X{c-user-agent}', '%X{c-client-id}', '%X{cs-bytes}', '%X{scbytes}', '%X{x-stream-id}', '%X{x-spos}','%X{cs-stream-bytes}', '%X{sc-stream-bytes}', '%X{x-sname}', '%X{x-sname-query}', '%X{x-file-name}', '%X{x-file-ext}', '%X{x-file-size}', '%X{x-file-length}','%X{x-suri}','%X{x-suri-stem}', '%X{x-suri-query}', '%X{c-suri-stem}', '%X{c-suri-query}');
Then restart Wowza and check the table:
SELECT * FROM AccessLog
Have fun,
Attila