Hi!

I've added wowza-cookie and wowza-host values to log lines.
I have class LoggingClientId:


package com.mycompany.wms.util;

import com.wowza.wms.client.*;
import com.wowza.wms.logging.*;
import com.wowza.wms.stream.*;
import com.wowza.wms.vhost.*;
import org.apache.log4j.Level;


public class LoggingClientId implements ILogNotify {

public static final String WOWZACOOKIENAME = "wowza-cookie";
public static final String WOWZAHOSTNAME = "wowza-host";

public void onLog(Level level, String comment, IMediaStream stream, String category, String event, int status, String context) {
Thread currThread = Thread.currentThread();

String wowzaCookie = null;
String wowzaHost = null;

while(true) {
if (!(currThread instanceof VHostWorkerThread))
break;

IVHost vhost = ((VHostWorkerThread)currThread).getVHost();
if (vhost == null)
break;

Integer clientIdObj = (Integer)WMSLoggerFactory.getGlobalLogValue(WMSLog gerIDs.FD_c_client_id);
if (clientIdObj == null)
break;

int clientId = clientIdObj.intValue();
IClient client = vhost.getClient(clientId);
if (client == null)
break;

wowzaCookie = client.getProperties().getPropertyStr(WOWZACOOKIEN AME);
wowzaHost = client.getProperties().getPropertyStr(WOWZAHOSTNAM E);

break;

}

WMSLoggerFactory.putGlobalLogValue(WOWZACOOKIENAME , wowzaCookie);
WMSLoggerFactory.putGlobalLogValue(WOWZAHOSTNAME, wowzaHost);

}

}


client object has property "wowza-cookie" and "wowza-host" initialized while connecting (onConnect)

I'm running Wowza with option -Dcom.wowza.wms.logging.LogNotify=com.mycompany.wms .util

I have configured log format in file /usr/local/WowzaMediaServerPro/conf/log4j.properties:

log4j.rootCategory=INFO, stdout, serverAccess, serverError, serverStats

# The logging context is
#log4j.logger.[vhost].[application].[appInstance]

# Field list
#date,time,tz,x-event,x-category,x-severity,x-status,x-ctx,x-comment,x-vhost,x-app,x-appinst,x-duration,s-ip,s-port,s-uri,c-ip,c-proto,c-referrer,c-user-agent,c-client-id,cs-bytes,sc-bytes,x-stream-id,x-spos,cs-stream-bytes,sc-stream-bytes,x-sname,x-sname-query,x-file-name,x-file-ext,x-file-size,x-file-length,x-suri,x-suri-stem,x-suri-query,cs-uri-stem,cs-uri-query

# Category list
#server,vhost,application,session,stream,rtsp

# Event list
#connect-pending,connect,disconnect,publish,unpublish,play, pause,setbuffertime,create,destroy,setstreamtype,u npause,seek,stop,record,recordstop,server-start,server-stop,vhost-start,vhost-stop,app-start,app-stop,comment,announce

# To force UTF-8 encoding of log values add the following property to the appender definition (where [appender] is the name of the appender such as "stdout" or "R")
#log4j.appender.[appender].encoding=UTF-8

# Console appender
log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
log4j.appender.stdout.layout=com.wowza.wms.logging .ECLFPatternLayout
log4j.appender.stdout.layout.Fields=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

# Access appender
log4j.appender.serverAccess=org.apache.log4j.Daily RollingFileAppender
log4j.appender.serverAccess.DatePattern='.'yyyy-MM-dd
log4j.appender.serverAccess.File=/var/log/gr/wowza/access.log
log4j.appender.serverAccess.layout=com.wowza.wms.l ogging.ECLFPatternLayout
log4j.appender.serverAccess.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,sc-stream-bytes,cs-stream-bytes,x-file-size,x-file-length,x-ctx,x-comment
log4j.appender.serverAccess.layout.OutputHeader=tr ue
log4j.appender.serverAccess.layout.QuoteFields=fal se
log4j.appender.serverAccess.layout.Delimeter=tab

# Error appender
log4j.appender.serverError=org.apache.log4j.DailyR ollingFileAppender
log4j.appender.serverError.DatePattern='.'yyyy-MM-dd
log4j.appender.serverError.File=/var/log/wowza/error.log
log4j.appender.serverError.layout=com.wowza.wms.lo gging.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,sc-stream-bytes,cs-stream-bytes,x-file-size,x-file-length,x-ctx,x-comment
log4j.appender.serverError.layout.OutputHeader=tru e
log4j.appender.serverError.layout.QuoteFields=fals e
log4j.appender.serverError.layout.Delimeter=tab
log4j.appender.serverError.Threshold=WARN

# Statistics appender (to use this appender add "serverStats" to the list of appenders in the first line of this file)
log4j.appender.serverStats=org.apache.log4j.DailyR ollingFileAppender
log4j.appender.serverStats.DatePattern='.'yyyy-MM-dd
log4j.appender.serverStats.File=/var/log/gr/wowza/stats.log
log4j.appender.serverStats.layout=com.wowza.wms.lo gging.ECLFPatternLayout
log4j.appender.serverStats.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,sc-stream-bytes,cs-stream-bytes,x-file-size,x-file-length,x-ctx,x-comment,wowza-cookie,wowza-host
log4j.appender.serverStats.layout.OutputHeader=tru e
log4j.appender.serverStats.layout.QuoteFields=fals e
log4j.appender.serverStats.layout.Delimeter=tab
log4j.appender.serverStats.layout.CategoryInclude= session,stream,server
log4j.appender.serverStats.layout.EventExclude=com ment


Unfortunately, it doesn't work. More precisely, somethimes is is working, but somethimes not and it looks like it is non-deterministic. Sample logs:

For this user it works:

INFO session connect-pending 2011-03-08 14:31:25 1331482685 X.X.X.X - 3456 3073 0.1 - - - - -- X.X.X.X - - -
INFO session connect 2011-03-08 14:31:25 1331482685 X.X.X.X - 3456 3073 0.101 - - - - - -X.X.X.X - 911c98283e51ca34f51b272b502aa6f0 test-1.xxx.1292323602
INFO stream create 2011-03-08 14:31:25 1331482685 X.X.X.X - 3575 3361 0.0 - 1 0 0 - -- - 911c98283e51ca34f51b272b502aa6f0 test-1.xxx.1292323602
INFO stream play 2011-03-08 14:31:25 1331482685 X.X.X.X - 3620 3403 0.314 http://localhost:9000/2 1 0 0- - http://localhost:9000/2 - 911c98283e51ca34f51b272b502aa6f0 test-1.xxx.1292323602
INFO stream stop 2011-03-08 15:20:37 1331482685 X.X.X.X - 4780 9779419 2952.133 http://localhost:9000/2 1 9273452 0 - - http://localhost:9000/2 - 911c98283e51ca34f51b272b502aa6f0 test-1.xxx.1292323602
INFO stream destroy 2011-03-08 15:20:37 1331482685 X.X.X.X - 4780 9779639 2952.134 http://localhost:9000/2 1 9273452 0 - - http://localhost:9000/2 - - -
INFO session disconnect 2011-03-08 15:20:37 1331482685 X.X.X.X - 4780 9779639 2952.34 - - - - -- 1331482685 - - -


For this user it doesn't work:

INFO session connect-pending 2011-03-08 08:27:30 554728637 X.X.X.X - 3456 3073 0.092 - - - - -- X.X.X.X - - -
INFO session connect 2011-03-08 08:27:30 554728637 X.X.X.X - 3456 3073 0.092 - - - - - -X.X.X.X - 6d66099d6009cce70de73d0134bf84c1 test-1.xxx.1292323602
INFO stream create 2011-03-08 08:27:30 554728637 X.X.X.X - 3575 3361 0.0 - 1 0 0 - -- - 6d66099d6009cce70de73d0134bf84c1 test-1.xxx.1292323602
INFO stream play 2011-03-08 08:27:31 554728637 X.X.X.X - 3621 3403 0.376 http://localhost:9000/51 1 00 - - http://localhost:9000/51 - 6d66099d6009cce70de73d0134bf84c1 test-1.xxx.1292323602
INFO stream stop 2011-03-08 15:25:39 554728637 X.X.X.X - 13247 83030123 25088.599 http://localhost:9000/51 1 78771483 0 - - http://localhost:9000/51 - - -
INFO stream destroy 2011-03-08 15:25:39 554728637 X.X.X.X - 13247 83030123 25088.599 http://localhost:9000/51 1 78771483 0 - - http://localhost:9000/51 - - -
INFO session disconnect 2011-03-08 15:25:39 554728637 X.X.X.X - 13247 83030123 25088.898 - - -- - - 554728637 - - -

When user is connecting wowza-cookie and wowza-host is always logged. The problem appears when stream is stopping - very often (about 50% of logs) wowza-host and wowza-cookie is not logged. It looks like client object may be destroyed before stream stop log is maked, but I'm not sure.

Do you have any ideas how to fix this?
Currenty I'm using Wowza Media Server Pro 1.7.0