Adding a custom log file and custom log fields.

Hi,

I am trying to create a custom logfile and custom log fields for logging.

I am using the API’s guide/example ( WowzaMediaServer_ServerSideAPI.pdf ) on page 687.

It states that after creating a class with custom Global Log Values I should edit the :

[install-dir]/bin/WowzaMediaServerPro-Service.conf

and add some Java Additional Parameters.

If on Windows, also edit

[install-dir]/bin/WowzaMediaServerPro-Service.conf

and add

wrapper.java.additional.[n]=-Dcom.wowza.wms.logging.LogNotify=[full-path-to-your-ILogNotify-class]

to the Java Additional Parameters section where [n] is the next number in the list of active parameters.

My problem is that i do not have this file.

I have Windows 7, Wowza Media Server 3.6.3 and I am using the startup/shutdown scripts to start and stop the server.

Should I create this file and put:

wrapper.java.additional.[1]=-
Dcom.wowza.wms.logging.LogNotify=[full-path-to-your-ILogNotify-class]

???

Any help will be greatly appreciated.

I think you are on the right track here. I suggest skipping the step of editing “WowzaMediaServerPro-Service.conf” and try it out. Some of the Wowza documentation may be in need of updating.

Salvadore

Sorry, I was out yesterday. I’ve been through this and getting same result. Everything is working correctly except getting those values are not in the log. I assume the configuration change is affecting this. I will have to get back to you.

Richard

Sorry, we did discuss, have to try a couple of things and get back to you.

Richard

In the /bin/startup.bat file, look for:

set JMXOPTIONS=-Dcom.sun.management.jmxremote=true

Add the NewLog class there:

set JMXOPTIONS=-Dcom.sun.management.jmxremote=true -Dcom.wowza.wms.logging.LogNotify=test.NewLog

Testing again, I have this working, and you do need that line in the /bin/startup.bat for the custom fields to work in Windows. The JMXOptions variable name is confusing this case, but notice that I have added the package.ClassName of the .java file:

-Dcom.wowza.wms.logging.LogNotify=test.NewLog

set JMXOPTIONS=-Dcom.sun.management.jmxremote=true -Dcom.wowza.wms.logging.LogNotify=test.NewLog

Make sure you use same package.ClassName as in the .java file in the above setting.

package test;
	
import org.apache.log4j.Level;
import com.wowza.wms.logging.ILogNotify;
import com.wowza.wms.logging.WMSLoggerFactory;
import com.wowza.wms.stream.IMediaStream;
public class NewLog implements ILogNotify {
    public void onLog(Level level, String comment, IMediaStream stream, String category,
            String event, int status, String context) {
        
        long systime = System.nanoTime();
        
        WMSLoggerFactory.putGlobalLogValue("CustomField1", systime);
        WMSLoggerFactory.putGlobalLogValue("CustomField2", systime + " LOGTEST");
        
    }
}

And that you add the custom fields to some appender in /conf/Log4j.properties.

For my test, I added them to the Console and Access appenders Fields list, as shown here in the Console Appender:

# Console appender
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=com.wowza.wms.logging.ECLFPatternLayout
log4j.appender.stdout.layout.Fields=CustomField1, CustomField2, x-severity,x-category,x-event,x-ctx,x-comment
log4j.appender.stdout.layout.OutputHeader=false
log4j.appender.stdout.layout.QuoteFields=false
log4j.appender.stdout.layout.Delimeter=space

Which yields output like this:

133566221916527 133566221916527 LOGTEST - INFO server server-start Wowza Media Server 3 Monthly Edition 3.6.4 build9641 -
133566223752470 133566223752470 LOGTEST - INFO server comment - Server License Key: SVRM3-XXXXX-XXXXX-XXXXX-XXXXX-BCTCu
133566224194161 133566224194161 LOGTEST - INFO server comment - Maximum Connections: Unlimited
133566227165881 133566227165881 LOGTEST - INFO server comment - Transcoder Streams Available: Unlimited
133566227577162 133566227577162 LOGTEST - INFO server comment - Transcoder Watermark: No
133566227986163 133566227986163 LOGTEST - INFO server comment - nDVR Available: Yes
133566228358294 133566228358294 LOGTEST - INFO server comment - DRM Available: Yes
133566228783639 133566228783639 LOGTEST - INFO server comment - Hardware Available Processors: 8
133566229403603 133566229403603 LOGTEST - INFO server comment - Hardware Physical Memory: 2927MB/7915MB
133566229781815 133566229781815 LOGTEST - INFO server comment - Hardware Swap Space: 9788MB/15828MB
133566230218184 133566230218184 LOGTEST - INFO server comment - Max File Descriptor Count: Unlimited
133566230680781 133566230680781 LOGTEST - INFO server comment - OS Name: Windows 7
133566231118671 133566231118671 LOGTEST - INFO server comment - OS Version: 6.1
133566231479778 133566231479778 LOGTEST - INFO server comment - OS Architecture: amd64

Rchard

Actually, it would be less confusing, though not be any different essentially, to add that line at the bottom of the /bin/startup.bat file after %JMXOPTIONS% like this:

%_EXESERVER% "%_EXECJAVA%" %JAVA_OPTS% %JMXOPTIONS% -Dcom.wowza.wms.logging.LogNotify=test.NewLog -Dcom.wowza.wms.runmode="%runmode%" -Dcom.wowza.wms.native.base="win" -Dcom.wowza.wms.ConfigURL="%WMSCONFIG_URL%" -cp %CLASSPATH% com.wowza.wms.bootstrap.Bootstrap start

Richard

I don’t think so, it’s not in the steps in the guide. Are you having a problem with that?

Richard

Hi,

There should be a comment in the startup.bat file which outlines where to make a change.

Andrew

Hi,

Are you running Wowza in the IDE? If so, you will need to edit your project run or debug configuration and add the the following to the VM Arguments on the Arguments tab.

-Dcom.wowza.wms.logging.LogNotify=[your.custom.Class]

The IDE does not use the files in the [install-dir]/bin folder when running Wowza.

Roger.

I need an answer to this as well. For the same reason. I am installing Willow to manage wowza and there is no WowzaMediaServerPro-Service.conf to edit.

OK I am now one step further by omitting the part with the “WowzaMediaServerPro-Service.conf”.

My log file is now created and I assume that the custom fields are being generated.

The problem is now that they are always empty (-).

They don’t seem to get evaluated at all.

Here is my class definition:

public class NewLog implements ILogNotify {
    public void onLog(Level level, String comment, IMediaStream stream, String category,
            String event, int status, String context) {
        
        long systime = System.nanoTime();
        
        WMSLoggerFactory.putGlobalLogValue("CustomField1", systime);
        WMSLoggerFactory.putGlobalLogValue("CustomField2", systime + " LOGTEST");
        
    }
}

Here is part of my log4j.properties file:

log4j.rootCategory=INFO, stdout, serverAccess, serverError, newinfo
..
..
# Error appender
log4j.appender.serverError=org.apache.log4j.DailyRollingFileAppender
log4j.appender.serverError.DatePattern='.'yyyy-MM-dd
log4j.appender.serverError.File=${com.wowza.wms.ConfigHome}/logs/wowzamediaserver_error.log
log4j.appender.serverError.layout=com.wowza.wms.logging.ECLFPatternLayout
log4j.appender.serverError.layout.Fields=x-severity,x-category,x-event;date,time,c-client-id,c-ip,c-port,cs-bytes,sc-bytes,x-duration,x-sname,x-stream-id,x-spos,sc-stream-bytes,cs-stream-bytes,x-file-size,x-file-length,x-ctx,x-comment,CustomField1,CustomField2
log4j.appender.serverError.layout.OutputHeader=true
log4j.appender.serverError.layout.QuoteFields=false
log4j.appender.serverError.layout.Delimeter=tab
log4j.appender.serverError.Threshold=WARN
..
################
# Custom Log File
log4j.appender.newinfo=org.apache.log4j.DailyRollingFileAppender
log4j.appender.newinfo.DatePattern='.'yyyy-MM-dd
log4j.appender.newinfo.File=${com.wowza.wms.ConfigHome}/logs/wowzamediaserver_newinfo.log
log4j.appender.newinfo.layout=com.wowza.wms.logging.ECLFPatternLayout
log4j.appender.newinfo.layout.Fields=date,time,tz,x-event,x-category,x-severity,x-status,CustomField1,CustomField2
log4j.appender.newinfo.layout.OutputHeader=true
log4j.appender.newinfo.layout.QuoteFields=false
log4j.appender.newinfo.layout.Delimeter=tab
log4j.appender.newinfo.Threshold=WARN
################

As you can see I have added the Custom fields in the error appender in order to check if I am getting anything there.

My output for the error appender is :

#Version: 1.0
#Start-Date: 2013-12-18 15:52:01 EET
#Software: Wowza Media Server 3.6.3 build8031
#Date: 2013-12-18
#Fields: x-severity	x-category	x-event	date	time	c-client-id	c-ip	c-port	cs-bytes	sc-bytes	x-duration	x-sname	x-stream-id	x-spos	sc-stream-bytes	cs-stream-bytes	x-file-size	x-file-length	x-ctx	x-comment	CustomField1	CustomField2
ERROR	server	comment	2013-12-18	15:52:01	-	-	-	-	-	0.164	-	-	-	-	-	-	-	-	ServerUtils.loadServerListener: Error creating <ServerListener> (com.wmspanel.WmsPanelAgent): java.lang.ClassNotFoundException: com.wmspanel.WmsPanelAgent	-	-
WARN	server	comment	2013-12-18	15:52:06	-	-	-	-	-	5.205	-	-	-	-	-	-	-	-	loadModFunctions[edge/_definst_]: Module class not found or could not be loaded. Check [install-dir]/conf/edge/Application.xml to be sure all Modules/Module/Class paths are correct: name:Wmsauth class:com.wmspanel.Wmsauth	-	-
WARN	server	comment	2013-12-18	15:52:18	-	-	-	-	-	17.625	-	-	-	-	-	-	-	-	LiveMediaStreamReceiver.doWatchdog: streamTimeout[live/_definst_/teststream]: Resetting connection: [removed ip]:1935/live/_definst_/teststream     -	-
WARN	server	comment	2013-12-18	15:52:31	-	-	-	-	-	30.626	-	-	-	-	-	-	-	-	LiveMediaStreamReceiver.doWatchdog: streamTimeout[live/_definst_/teststream]: Resetting connection: [removed ip]:1935/live/_definst_/teststream	-	-

and for the custom appender:

#Version: 1.0
#Start-Date: 2013-12-18 15:52:01 EET
#Software: Wowza Media Server 3.6.3 build8031
#Date: 2013-12-18
#Fields: date	time	tz	x-event	x-category	x-severity	x-status	CustomField1	CustomField2
2013-12-18	15:52:01	EET	comment	server	ERROR	500	-	-
2013-12-18	15:52:06	EET	comment	server	WARN	200	-	-
2013-12-18	15:52:18	EET	comment	server	WARN	200	-	-
2013-12-18	15:52:31	EET	comment	server	WARN	200	-	-
2013-12-18	15:52:44	EET	comment	server	WARN	200	-	-
2013-12-18	15:52:56	EET	comment	server	WARN	200	-	-
2013-12-18	15:53:09	EET	comment	server	WARN	200	-	-
2013-12-18	15:53:21	EET	comment	server	WARN	200	-	-

Is there anything else I should do in order to have those fields evaluated?

Hi,

Are you running Wowza in the IDE? If so, you will need to edit your project run or debug configuration and add the the following to the VM Arguments on the Arguments tab.

-Dcom.wowza.wms.logging.LogNotify=[your.custom.Class]

The IDE does not use the files in the [install-dir]/bin folder when running Wowza.

Roger.

I am not running the IDE. I am using Netbeans and then I copy the .jar files in the [wowza]/lib folder

Ok. I am out of ideas…

Does anybody know how to do this??

Documentation on the api is nonexistent!

OK thanks.

Just for the record I did try to create a “WowzaMediaServerPro-Service.conf” file and add the

wrapper.java.additional.[1]=-
Dcom.wowza.wms.logging.LogNotify=[full-path-to-your-ILogNotify-class]

but again with no results.

Hello guys,

Anybody had any insights with this?

It has been a long time ago since I have asked for some information with this.

I don’t want to give it up but I would like to see it through.

I am awaiting for your reply.

Hello,

I suppose this is not an answer for my original question and it only applies to managing wowza through JMX.

So, after hijacking the thread, my original question still stands.

Is there a way to add a custom log file and custom log fields?

Testing again, I have this working, and you do need that line in the /bin/startup.bat for the custom fields…

Rchard

Thank you for your reply and help Richard. This works indeed.

In case of a Linux installation scenario do I need to make any changes to the [wowza install dir]/bin/startup.sh???