diff -ur motion-20140827-051001/stream.c motion-20140827-051001-streamlogging/stream.c
--- motion-20140827-051001/stream.c	2014-08-27 04:10:02.000000000 +0100
+++ motion-20140827-051001-streamlogging/stream.c	2015-08-16 10:39:03.000000000 +0100
@@ -27,6 +27,8 @@
 #include <ctype.h>
 #include <sys/fcntl.h>
 
+#include <openssl/hmac.h>
+
 #define STREAM_REALM       "Motion Stream Security Access"
 #define KEEP_ALIVE_TIMEOUT 100
 
@@ -160,6 +162,34 @@
 static void stream_add_client(struct stream *list, int sc);
 
 /**
+ * log_fail_basic
+ *
+ * openssl decode_base64 and log it.
+ *
+ */
+char *log_fail_basic(char *input, int length)
+{
+  BIO *b64, *bmem;
+
+  char *buffer = (char *)malloc(length);
+  memset(buffer, 0, length);
+
+  b64 = BIO_new(BIO_f_base64());
+  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
+  bmem = BIO_new_mem_buf(input, length);
+  bmem = BIO_push(b64, bmem);
+
+  BIO_read(bmem, buffer, length);
+
+  BIO_free_all(bmem);
+
+  MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO, "%s: Stream basic auth failed: %s ", buffer);
+
+  return 0;
+}
+
+
+/**
  * handle_basic_auth
  *
  *
@@ -215,9 +245,11 @@
 
         if (strcmp(auth, authentication)) {
             free(authentication);
+            log_fail_basic(auth, strlen(auth));
             goto Error;
         }
         free(authentication);
+	 MOTION_LOG(WRN, TYPE_STREAM, NO_ERRNO, "%s: Stream basic auth succeeded");
     }
 
     // OK - Access
@@ -558,6 +590,8 @@
 
         if (strcmp(server_response, response) == 0)
             break;
+            MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO, "%s: Stream digest auth failed: User %s", username);
+
 Error:
         rand1 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0));
         rand2 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0));
@@ -574,6 +608,7 @@
     }
 
     // OK - Access
+    MOTION_LOG(WRN, TYPE_STREAM, NO_ERRNO, "%s: Stream digest auth succeeded");
 
     /* Set socket to non blocking */
     if (fcntl(p->sock, F_SETFL, p->sock_flags) < 0) {
@@ -788,6 +823,36 @@
     return sl;
 }
 
+/** 
+ * log_ip
+ *
+ *
+ * Get and log remote IP address and port on stream connect.
+ *         Handles both IPv4 and IPv6.
+ */
+void log_ip(int s)
+{
+    socklen_t len;
+    struct sockaddr_storage addr;
+    char ipstr[INET6_ADDRSTRLEN];
+    int port;
+    len = sizeof addr;
+    getpeername(s, (struct sockaddr*)&addr, &len);
+ 
+    if (addr.ss_family == AF_INET) {
+        struct sockaddr_in *s = (struct sockaddr_in *)&addr;
+        port = ntohs(s->sin_port);
+        inet_ntop(AF_INET, &s->sin_addr, ipstr, sizeof ipstr);
+    } else {
+        struct sockaddr_in6 *s = (struct sockaddr_in6 *)&addr;
+        port = ntohs(s->sin6_port);
+        inet_ntop(AF_INET6, &s->sin6_addr, ipstr, sizeof ipstr);
+    }
+
+    MOTION_LOG(WRN, TYPE_STREAM, NO_ERRNO, "%s: Connection from %s:%d", ipstr, port);
+    return;
+}
+
 /**
  * http_acceptsock
  *
@@ -802,6 +867,7 @@
     socklen_t addrlen = sizeof(sin);
 
     if ((sc = accept(sl, (struct sockaddr *)&sin, &addrlen)) >= 0) {
+        log_ip(sc);
         i = 1;
         ioctl(sc, FIONBIO, &i);
         return sc;
diff -ur motion-20140827-051001/stream.h motion-20140827-051001-streamlogging/stream.h
--- motion-20140827-051001/stream.h	2014-08-27 04:10:02.000000000 +0100
+++ motion-20140827-051001-streamlogging/stream.h	2015-08-16 10:39:23.000000000 +0100
@@ -42,4 +42,7 @@
 void stream_put(struct context *, unsigned char *);
 void stream_stop(struct context *);
 
+void log_ip(int s);
+char *log_fail_basic(char *input, int length);
+
 #endif /* _INCLUDE_STREAM_H_ */
diff -ur motion-20140827-051001/track.c motion-20140827-051001-streamlogging/track.c
--- motion-20140827-051001/track.c	2014-08-27 04:10:02.000000000 +0100
+++ motion-20140827-051001-streamlogging/track.c	2015-08-16 10:23:01.000000000 +0100
@@ -8,6 +8,7 @@
 
 #include <math.h>
 #include "motion.h"
+#include <linux/videodev2.h>
 
 #if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L))
 #include "pwc-ioctl.h"
