This article describes how to set up Wowza Streaming Engine™ media server software logging to a MySQL database using the Apache Log4j 2 logging utility.
Notes:
- The instructions in this article apply to Wowza Streaming Engine 4.8.8.01 and later. For version 4.8.5 and earlier, see Store Wowza Streaming Engine logs in a MySQL database (legacy).
- Database logging is provided by the Log4j logging system, which Wowza Streaming Engine uses for its logging framework. There have been reports of issues with database logging when the connection to the database is lost. The Log4j system will not automatically try to reconnect to the database server.
- Download the MySQL JDBC Connector, then open the ZIP file and extract the file mysql-connector-java-8.0.20.jar file to the Wowza Streaming Engine installation folder [install-dir]/lib.
- In MySQL, create a catalog named wowzalogs. Then create the following table to store the Wowza Streaming Engine log fields. (Table attributes have the same name as Log4j fields but without hyphens.)
CREATE TABLE `wowzalogs`.`accesslog` ( `logid` int(10) unsigned NOT NULL AUTO_INCREMENT, `date` varchar(100) DEFAULT NULL, `time` varchar(100) DEFAULT NULL, `tz` varchar(100) DEFAULT NULL, `xevent` varchar(20) DEFAULT NULL, `xcategory` varchar(20) DEFAULT NULL, `xseverity` varchar(100) DEFAULT NULL, `xstatus` varchar(100) DEFAULT NULL, `xctx` varchar(100) DEFAULT NULL, `xcomment` varchar(255) DEFAULT NULL, `xvhost` varchar(100) DEFAULT NULL, `xapp` varchar(100) DEFAULT NULL, `xappinst` varchar(100) DEFAULT NULL, `xduration` varchar(100) DEFAULT NULL, `sip` varchar(100) DEFAULT NULL, `sport` varchar(100) DEFAULT NULL, `suri` varchar(255) DEFAULT NULL, `cip` varchar(100) DEFAULT NULL, `cproto` varchar(100) DEFAULT NULL, `creferrer` varchar(255) DEFAULT NULL, `cuseragent` varchar(100) DEFAULT NULL, `cclientid` varchar(25) DEFAULT NULL, `csbytes` varchar(20) DEFAULT NULL, `scbytes` varchar(20) DEFAULT NULL, `xstreamid` varchar(20) DEFAULT NULL, `xspos` varchar(20) DEFAULT NULL, `csstreambytes` varchar(20) DEFAULT NULL, `scstreambytes` varchar(20) DEFAULT NULL, `xsname` varchar(100) DEFAULT NULL, `xsnamequery` varchar(100) DEFAULT NULL, `xfilename` varchar(100) DEFAULT NULL, `xfileext` varchar(100) DEFAULT NULL, `xfilesize` varchar(100) DEFAULT NULL, `xfilelength` varchar(100) DEFAULT NULL, `xsuri` varchar(255) DEFAULT NULL, `xsuristem` varchar(255) DEFAULT NULL, `xsuriquery` varchar(255) DEFAULT NULL, `csuristem` varchar(255) DEFAULT NULL, `csuriquery` varchar(255) DEFAULT NULL, `classfqcn` varchar(255) DEFAULT NULL, `xclassname` varchar(100) DEFAULT NULL, `xclasspackagename` varchar(255) DEFAULT NULL, `xvhostcontext` varchar(100) DEFAULT NULL, `xappcontext` varchar(100) DEFAULT NULL, `xappinstcontext` varchar(100) DEFAULT NULL, PRIMARY KEY (`logid`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
- Open the Wowza Streaming Engine file [install-dir]/conf/log4j2-config.xml in a text editor.
- At the beginning of the <Appenders> block, add this <JDBC> block, using your unique values for username and password:
<JDBC name="wowzalogs" tableName="accesslog"> <DriverManager connectionString="jdbc:mysql://localhost:3306/wowzalogs" driverClassName="com.mysql.cj.jdbc.Driver" username="[your-username]" password="[your-password]" /> <Column name="date" pattern="%X{date}" /> <Column name="time" pattern="%X{time}" /> <Column name="tz" pattern="%X{tz}" /> <Column name="xevent" pattern="%X{x-event}" /> <Column name="xcategory" pattern="%X{x-category}" /> <Column name="xseverity" pattern="%X{x-severity}" /> <Column name="xstatus" pattern="%X{x-status}" /> <Column name="xctx" pattern="%X{x-ctx}" /> <Column name="xcomment" pattern="%X{x-comment}" /> <Column name="xvhost" pattern="%X{x-vhost}" /> <Column name="xapp" pattern="%X{x-app}" /> <Column name="xappinst" pattern="%X{x-appinst}" /> <Column name="xduration" pattern="%X{x-duration}" /> <Column name="sip" pattern="%X{s-ip}" /> <Column name="sport" pattern="%X{sport}" /> <Column name="suri" pattern="%X{s-uri}" /> <Column name="cip" pattern="%X{c-ip}" /> <Column name="cproto" pattern="%X{c-proto}" /> <Column name="creferrer" pattern="%X{c-referrer}" /> <Column name="cuseragent" pattern="%X{c-user-agent}" /> <Column name="cclientid" pattern="%X{c-client-id}" /> <Column name="csbytes" pattern="%X{cs-bytes}" /> <Column name="scbytes" pattern="%X{scbytes}" /> <Column name="xstreamid" pattern="%X{x-stream-id}" /> <Column name="xspos" pattern="%X{x-spos}" /> <Column name="csstreambytes" pattern="%X{cs-stream-bytes}" /> <Column name="scstreambytes" pattern="%X{sc-stream-bytes}" /> <Column name="xsname" pattern="%X{x-sname}" /> <Column name="xsnamequery" pattern="%X{x-sname-query}" /> <Column name="xfilename" pattern="%X{x-file-name}" /> <Column name="xfileext" pattern="%X{x-file-ext}" /> <Column name="xfilesize" pattern="%X{x-file-size}" /> <Column name="xfilelength" pattern="%X{x-file-length}" /> <Column name="xsuri" pattern="%X{x-suri}" /> <Column name="xsuristem" pattern="%X{x-suri-stem}" /> <Column name="xsuriquery" pattern="%X{x-suri-query}" /> <Column name="csuristem" pattern="%X{c-suri-stem}" /> <Column name="csuriquery" pattern="%X{c-suri-query}" /> <Column name="classfqcn" pattern="%X{x-class-fqcn}" /> <Column name="xclassname" pattern="%X{x-class-name}" /> <Column name="xclasspackagename" pattern="%X{x-class-packagename}" /> <Column name="xvhostcontext" pattern="%X{x-vhost-context}" /> <Column name="xappcontext " pattern="%X{x-app-context}" /> <Column name="xappinstcontext" pattern="%X{x-appinst-context}" /> </JDBC>
- Add this appender reference to the <Loggers>/<Root level="info> block at the end of the log4j2-config.xml file:
<AppenderRef ref="wowzalogs" level="info"/>
- Save the file and restart Wowza Streaming Engine.
- To monitor the log in the database, enter the following in a command prompt:
SELECT * FROM wowzalogs.accesslog;
Alternatively, use MySQL Workbench to monitor the table for data.
Notes:
- Start Wowza Streaming Engine in the console or IDE to see any errors that occur.
- Some fields might need to be longer to accommodate all possible values.