bug 1219466 - convert netwerk to LazyLogModule r=valentin.gosu
authorPatrick McManus <mcmanus@ducksong.com>
Mon, 02 Nov 2015 23:35:29 -0500
changeset 270894 bb906bd012a20249b63f6feee8a421e15ae644ce
parent 270893 19e021ef5ba1fbac2ad7820be8e9089c5f855c67
child 270895 7b99659430b166a6bb42129cd3cb5d48cd0e3f56
push id29626
push usercbook@mozilla.com
push dateTue, 03 Nov 2015 11:00:46 +0000
treeherdermozilla-central@bb4d614a0b09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1219466
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1219466 - convert netwerk to LazyLogModule r=valentin.gosu
dom/base/nsDOMDataChannel.cpp
dom/network/UDPSocket.h
dom/network/UDPSocketChild.cpp
dom/network/UDPSocketParent.cpp
netwerk/base/BackgroundFileSaver.cpp
netwerk/base/BackgroundFileSaver.h
netwerk/base/CaptivePortalService.cpp
netwerk/base/Predictor.cpp
netwerk/base/nsAsyncRedirectVerifyHelper.cpp
netwerk/base/nsAsyncStreamCopier.cpp
netwerk/base/nsAutodialWin.cpp
netwerk/base/nsChannelClassifier.cpp
netwerk/base/nsDirectoryIndexStream.cpp
netwerk/base/nsInputStreamPump.cpp
netwerk/base/nsLoadGroup.cpp
netwerk/base/nsPACMan.cpp
netwerk/base/nsPACMan.h
netwerk/base/nsProtocolProxyService.cpp
netwerk/base/nsRequestObserverProxy.cpp
netwerk/base/nsSecCheckWrapChannel.cpp
netwerk/base/nsSocketTransportService2.cpp
netwerk/base/nsSocketTransportService2.h
netwerk/base/nsStandardURL.cpp
netwerk/cache/nsCache.cpp
netwerk/cache/nsCache.h
netwerk/cache/nsCacheService.cpp
netwerk/cache2/CacheLog.cpp
netwerk/cache2/CacheLog.h
netwerk/cookie/nsCookieService.cpp
netwerk/dns/GetAddrInfo.cpp
netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp
netwerk/dns/nsHostResolver.cpp
netwerk/protocol/ftp/nsFTPChannel.cpp
netwerk/protocol/ftp/nsFtpConnectionThread.cpp
netwerk/protocol/ftp/nsFtpControlConnection.cpp
netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
netwerk/protocol/ftp/nsFtpProtocolHandler.h
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/HttpLog.h
netwerk/protocol/http/PackagedAppService.cpp
netwerk/protocol/http/nsHttp.cpp
netwerk/protocol/http/nsHttpConnectionInfo.h
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/res/SubstitutingProtocolHandler.cpp
netwerk/protocol/rtsp/controller/RtspController.cpp
netwerk/protocol/rtsp/controller/RtspControllerChild.cpp
netwerk/protocol/rtsp/controller/RtspControllerParent.cpp
netwerk/protocol/rtsp/rtsp/RTSPConnectionHandler.h
netwerk/protocol/rtsp/rtsp/RtspPrlog.h
netwerk/protocol/websocket/BaseWebSocketChannel.cpp
netwerk/protocol/websocket/WebSocketChannelParent.cpp
netwerk/protocol/websocket/WebSocketLog.h
netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
netwerk/protocol/wyciwyg/nsWyciwyg.cpp
netwerk/protocol/wyciwyg/nsWyciwyg.h
netwerk/protocol/wyciwyg/nsWyciwygChannel.h
netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
netwerk/sctp/datachannel/DataChannel.cpp
netwerk/sctp/datachannel/DataChannelLog.h
netwerk/socket/nsSOCKSIOLayer.cpp
netwerk/streamconv/converters/nsFTPDirListingConv.cpp
netwerk/streamconv/converters/nsFTPDirListingConv.h
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
netwerk/system/mac/nsNetworkLinkService.mm
netwerk/system/win32/nsNotifyAddrListener.cpp
netwerk/wifi/nsWifiAccessPoint.cpp
netwerk/wifi/nsWifiMonitor.cpp
netwerk/wifi/nsWifiMonitor.h
netwerk/wifi/nsWifiMonitorGonk.cpp
--- a/dom/base/nsDOMDataChannel.cpp
+++ b/dom/base/nsDOMDataChannel.cpp
@@ -4,36 +4,35 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMDataChannel.h"
 
 #include "base/basictypes.h"
 #include "mozilla/Logging.h"
 
-extern PRLogModuleInfo* GetDataChannelLog();
-#undef LOG
-#define LOG(args) MOZ_LOG(GetDataChannelLog(), mozilla::LogLevel::Debug, args)
-
-
 #include "nsDOMDataChannelDeclarations.h"
 #include "nsDOMDataChannel.h"
 #include "nsIDOMDataChannel.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/ScriptSettings.h"
 
 #include "nsError.h"
 #include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIScriptObjectPrincipal.h"
 
 #include "DataChannel.h"
+#include "DataChannelLog.h"
+
+#undef LOG
+#define LOG(args) MOZ_LOG(mozilla::gDataChannelLog, mozilla::LogLevel::Debug, args)
 
 // Since we've moved the windows.h include down here, we have to explicitly
 // undef GetBinaryType, otherwise we'll get really odd conflicts
 #ifdef GetBinaryType
 #undef GetBinaryType
 #endif
 
 using namespace mozilla;
--- a/dom/network/UDPSocket.h
+++ b/dom/network/UDPSocket.h
@@ -16,17 +16,17 @@
 #include "nsIUDPSocketChild.h"
 #include "nsTArray.h"
 
 struct JSContext;
 
 //
 // set NSPR_LOG_MODULES=UDPSocket:5
 //
-extern PRLogModuleInfo *gUDPSocketLog;
+extern mozilla::LazyLogModule gUDPSocketLog;
 #define UDPSOCKET_LOG(args)     MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args)
 #define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug)
 
 namespace mozilla {
 namespace dom {
 
 struct UDPOptions;
 class StringOrBlobOrArrayBufferOrArrayBufferView;
--- a/dom/network/UDPSocketChild.cpp
+++ b/dom/network/UDPSocketChild.cpp
@@ -15,17 +15,17 @@
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "nsIIPCBackgroundChildCreateCallback.h"
 
 using mozilla::net::gNeckoChild;
 
 //
 // set NSPR_LOG_MODULES=UDPSocket:5
 //
-extern PRLogModuleInfo *gUDPSocketLog;
+extern mozilla::LazyLogModule gUDPSocketLog;
 #define UDPSOCKET_LOG(args)     MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args)
 #define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug)
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ISUPPORTS(UDPSocketChildBase, nsIUDPSocketChild)
 
--- a/dom/network/UDPSocketParent.cpp
+++ b/dom/network/UDPSocketParent.cpp
@@ -20,17 +20,17 @@
 #include "mozilla/dom/TabParent.h"
 #include "nsIPermissionManager.h"
 #include "nsIScriptSecurityManager.h"
 #include "mozilla/ipc/PBackgroundParent.h"
 
 //
 // set NSPR_LOG_MODULES=UDPSocket:5
 //
-extern PRLogModuleInfo *gUDPSocketLog;
+extern mozilla::LazyLogModule gUDPSocketLog;
 #define UDPSOCKET_LOG(args)     MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args)
 #define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug)
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ISUPPORTS(UDPSocketParent, nsIUDPSocketListener)
 
--- a/netwerk/base/BackgroundFileSaver.cpp
+++ b/netwerk/base/BackgroundFileSaver.cpp
@@ -28,19 +28,19 @@
 #include <softpub.h>
 #include <wintrust.h>
 #endif // XP_WIN
 
 namespace mozilla {
 namespace net {
 
 // NSPR_LOG_MODULES=BackgroundFileSaver:5
-PRLogModuleInfo *BackgroundFileSaver::prlog = nullptr;
-#define LOG(args) MOZ_LOG(BackgroundFileSaver::prlog, mozilla::LogLevel::Debug, args)
-#define LOG_ENABLED() MOZ_LOG_TEST(BackgroundFileSaver::prlog, mozilla::LogLevel::Debug)
+static LazyLogModule prlog("BackgroundFileSaver");
+#define LOG(args) MOZ_LOG(prlog, mozilla::LogLevel::Debug, args)
+#define LOG_ENABLED() MOZ_LOG_TEST(prlog, mozilla::LogLevel::Debug)
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Globals
 
 /**
  * Buffer size for writing to the output file or reading from the input file.
  */
 #define BUFFERED_IO_SIZE (1024 * 32)
@@ -105,18 +105,16 @@ BackgroundFileSaver::BackgroundFileSaver
 , mRenamedTargetKeepPartial(false)
 , mAsyncCopyContext(nullptr)
 , mSha256Enabled(false)
 , mSignatureInfoEnabled(false)
 , mActualTarget(nullptr)
 , mActualTargetKeepPartial(false)
 , mDigestContext(nullptr)
 {
-  if (!prlog)
-    prlog = PR_NewLogModule("BackgroundFileSaver");
   LOG(("Created BackgroundFileSaver [this = %p]", this));
 }
 
 BackgroundFileSaver::~BackgroundFileSaver()
 {
   LOG(("Destroying BackgroundFileSaver [this = %p]", this));
   nsNSSShutDownPreventionLock lock;
   if (isAlreadyShutDown()) {
--- a/netwerk/base/BackgroundFileSaver.h
+++ b/netwerk/base/BackgroundFileSaver.h
@@ -20,17 +20,16 @@
 #include "nsIBackgroundFileSaver.h"
 #include "nsIStreamListener.h"
 #include "nsStreamUtils.h"
 #include "ScopedNSSTypes.h"
 
 class nsIAsyncInputStream;
 class nsIThread;
 class nsIX509CertList;
-struct PRLogModuleInfo;
 
 namespace mozilla {
 namespace net {
 
 class DigestOutputStream;
 
 ////////////////////////////////////////////////////////////////////////////////
 //// BackgroundFileSaver
@@ -69,18 +68,16 @@ public:
    * session finished, and this counter is reset.
    */
   static uint32_t sTelemetryMaxThreadCount;
 
 
 protected:
   virtual ~BackgroundFileSaver();
 
-  static PRLogModuleInfo *prlog;
-
   /**
    * Helper function for managing NSS objects (mDigestContext).
    */
   void destructorSafeDestroyNSSReference();
 
   /**
    * Thread that constructed this object.
    */
--- a/netwerk/base/CaptivePortalService.cpp
+++ b/netwerk/base/CaptivePortalService.cpp
@@ -11,23 +11,23 @@
 #define kInterfaceName "captive-portal-inteface"
 
 static const char kOpenCaptivePortalLoginEvent[] = "captive-portal-login";
 static const char kAbortCaptivePortalLoginEvent[] = "captive-portal-login-abort";
 static const char kCaptivePortalLoginSuccessEvent[] = "captive-portal-login-success";
 
 static const uint32_t kDefaultInterval = 60*1000; // check every 60 seconds
 
-static PRLogModuleInfo *gCaptivePortalLog = nullptr;
+namespace mozilla {
+namespace net {
+
+static LazyLogModule gCaptivePortalLog("CaptivePortalService");
 #undef LOG
 #define LOG(args) MOZ_LOG(gCaptivePortalLog, mozilla::LogLevel::Debug, args)
 
-namespace mozilla {
-namespace net {
-
 NS_IMPL_ISUPPORTS(CaptivePortalService, nsICaptivePortalService, nsIObserver,
                   nsISupportsWeakReference, nsITimerCallback,
                   nsICaptivePortalCallback)
 
 CaptivePortalService::CaptivePortalService()
   : mState(UNKNOWN)
   , mStarted(false)
   , mInitialized(false)
@@ -96,20 +96,16 @@ CaptivePortalService::RearmTimer()
 nsresult
 CaptivePortalService::Initialize()
 {
   if (mInitialized || XRE_GetProcessType() != GeckoProcessType_Default) {
     return NS_OK;
   }
   mInitialized = true;
 
-  if (!gCaptivePortalLog) {
-    gCaptivePortalLog = PR_NewLogModule("CaptivePortalService");
-  }
-
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
   if (observerService) {
     observerService->AddObserver(this, kOpenCaptivePortalLoginEvent, true);
     observerService->AddObserver(this, kAbortCaptivePortalLoginEvent, true);
     observerService->AddObserver(this, kCaptivePortalLoginSuccessEvent, true);
   }
 
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -51,17 +51,18 @@ static const int32_t ANDROID_23_VERSION 
 
 using namespace mozilla;
 
 namespace mozilla {
 namespace net {
 
 Predictor *Predictor::sSelf = nullptr;
 
-static PRLogModuleInfo *gPredictorLog = nullptr;
+static LazyLogModule gPredictorLog("NetworkPredictor");
+
 #define PREDICTOR_LOG(args) MOZ_LOG(gPredictorLog, mozilla::LogLevel::Debug, args)
 
 #define RETURN_IF_FAILED(_rv) \
   do { \
     if (NS_FAILED(_rv)) { \
       return; \
     } \
   } while (0)
@@ -317,18 +318,16 @@ Predictor::Predictor()
   ,mSubresourceDegradationMax(PREDICTOR_SUB_DELTA_MAX_DEFAULT)
   ,mPreconnectMinConfidence(PRECONNECT_MIN_DEFAULT)
   ,mPreresolveMinConfidence(PRERESOLVE_MIN_DEFAULT)
   ,mRedirectLikelyConfidence(REDIRECT_LIKELY_DEFAULT)
   ,mMaxResourcesPerEntry(PREDICTOR_MAX_RESOURCES_DEFAULT)
   ,mStartupCount(1)
   ,mMaxURILength(PREDICTOR_MAX_URI_LENGTH_DEFAULT)
 {
-  gPredictorLog = PR_NewLogModule("NetworkPredictor");
-
   MOZ_ASSERT(!sSelf, "multiple Predictor instances!");
   sSelf = this;
 }
 
 Predictor::~Predictor()
 {
   if (mInitialized)
     Shutdown();
--- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
+++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
@@ -8,26 +8,19 @@
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 
 #include "nsIOService.h"
 #include "nsIChannel.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 
+static mozilla::LazyLogModule gRedirectLog("nsRedirect");
 #undef LOG
-static PRLogModuleInfo *
-GetRedirectLog()
-{
-    static PRLogModuleInfo *sLog;
-    if (!sLog)
-        sLog = PR_NewLogModule("nsRedirect");
-    return sLog;
-}
-#define LOG(args) MOZ_LOG(GetRedirectLog(), mozilla::LogLevel::Debug, args)
+#define LOG(args) MOZ_LOG(gRedirectLog, mozilla::LogLevel::Debug, args)
 
 NS_IMPL_ISUPPORTS(nsAsyncRedirectVerifyHelper,
                   nsIAsyncVerifyRedirectCallback,
                   nsIRunnable)
 
 class nsAsyncVerifyRedirectCallbackEvent : public nsRunnable {
 public:
     nsAsyncVerifyRedirectCallbackEvent(nsIAsyncVerifyRedirectCallback *cb,
--- a/netwerk/base/nsAsyncStreamCopier.cpp
+++ b/netwerk/base/nsAsyncStreamCopier.cpp
@@ -14,17 +14,17 @@
 #include "mozilla/Logging.h"
 
 using namespace mozilla;
 
 #undef LOG
 //
 // NSPR_LOG_MODULES=nsStreamCopier:5
 //
-static PRLogModuleInfo *gStreamCopierLog = nullptr;
+static LazyLogModule gStreamCopierLog("nsStreamCopier");
 #define LOG(args) MOZ_LOG(gStreamCopierLog, mozilla::LogLevel::Debug, args)
 
 /**
  * An event used to perform initialization off the main thread.
  */
 class AsyncApplyBufferingPolicyEvent final: public nsRunnable
 {
 public:
@@ -65,18 +65,16 @@ private:
 nsAsyncStreamCopier::nsAsyncStreamCopier()
     : mLock("nsAsyncStreamCopier.mLock")
     , mMode(NS_ASYNCCOPY_VIA_READSEGMENTS)
     , mChunkSize(nsIOService::gDefaultSegmentSize)
     , mStatus(NS_OK)
     , mIsPending(false)
     , mShouldSniffBuffering(false)
 {
-    if (!gStreamCopierLog)
-        gStreamCopierLog = PR_NewLogModule("nsStreamCopier");
     LOG(("Creating nsAsyncStreamCopier @%x\n", this));
 }
 
 nsAsyncStreamCopier::~nsAsyncStreamCopier()
 {
     LOG(("Destroying nsAsyncStreamCopier @%x\n", this));
 }
 
--- a/netwerk/base/nsAutodialWin.cpp
+++ b/netwerk/base/nsAutodialWin.cpp
@@ -24,18 +24,17 @@
 //
 //    set NSPR_LOG_MODULES=Autodial:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables LogLevel::Debug level information and places all output in
 // the file nspr.log
 //
 
-static PRLogModuleInfo* gLog = nullptr;
-
+static mozilla::LazyLogModule gLog("Autodial");
 #undef LOGD
 #undef LOGE
 #define LOGD(args) MOZ_LOG(gLog, mozilla::LogLevel::Debug, args)
 #define LOGE(args) MOZ_LOG(gLog, mozilla::LogLevel::Error, args)
 
 // Don't try to dial again within a few seconds of when user pressed cancel.
 #define NO_RETRY_PERIOD_SEC 5
 PRIntervalTime nsAutodial::mDontRetryUntil = 0;
@@ -57,19 +56,16 @@ nsAutodial::~nsAutodial()
 }
 
 
 // Get settings from the OS. These are settings that might change during
 // the OS session. Call Init() again to pick up those changes if required.
 // Returns NS_ERROR_FAILURE if error or NS_OK if success.
 nsresult nsAutodial::Init()
 {
-    if (!gLog)
-        gLog = PR_NewLogModule("Autodial");
-
     mDefaultEntryName[0] = '\0';
     mNumRASConnectionEntries = 0;
     mAutodialBehavior = QueryAutodialBehavior();
     
     // No need to continue in this case.
     if (mAutodialBehavior == AUTODIAL_NEVER)
     {
         return NS_OK;
--- a/netwerk/base/nsChannelClassifier.cpp
+++ b/netwerk/base/nsChannelClassifier.cpp
@@ -35,30 +35,29 @@
 #include "mozilla/Preferences.h"
 
 using mozilla::ArrayLength;
 using mozilla::Preferences;
 
 //
 // NSPR_LOG_MODULES=nsChannelClassifier:5
 //
-static PRLogModuleInfo *gChannelClassifierLog;
+static mozilla::LazyLogModule gChannelClassifierLog("nsChannelClassifier");
+
 #undef LOG
 #define LOG(args)     MOZ_LOG(gChannelClassifierLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gChannelClassifierLog, mozilla::LogLevel::Debug)
 
 NS_IMPL_ISUPPORTS(nsChannelClassifier,
                   nsIURIClassifierCallback)
 
 nsChannelClassifier::nsChannelClassifier()
   : mIsAllowListed(false),
     mSuspendedChannel(false)
 {
-    if (!gChannelClassifierLog)
-        gChannelClassifierLog = PR_NewLogModule("nsChannelClassifier");
 }
 
 nsresult
 nsChannelClassifier::ShouldEnableTrackingProtection(nsIChannel *aChannel,
                                                     bool *result)
 {
     // Should only be called in the parent process.
     MOZ_ASSERT(XRE_IsParentProcess());
--- a/netwerk/base/nsDirectoryIndexStream.cpp
+++ b/netwerk/base/nsDirectoryIndexStream.cpp
@@ -13,18 +13,16 @@
   http://www.mozilla.org/projects/netlib/dirindexformat.html
 
  */
 
 #include "nsEscape.h"
 #include "nsDirectoryIndexStream.h"
 #include "mozilla/Logging.h"
 #include "prtime.h"
-static PRLogModuleInfo* gLog;
-
 #include "nsISimpleEnumerator.h"
 #ifdef THREADSAFE_I18N
 #include "nsCollationCID.h"
 #include "nsICollation.h"
 #include "nsILocale.h"
 #include "nsILocaleService.h"
 #endif
 #include "nsIFile.h"
@@ -36,22 +34,21 @@ static PRLogModuleInfo* gLog;
 // we want to do stuff like i18n sorting. However, none of the collation stuff
 // is threadsafe.
 // So THIS CODE IS ASCII ONLY!!!!!!!! This is no worse than the current
 // behaviour, though. See bug 99382.
 // When this is fixed, #define THREADSAFE_I18N to get this code working
 
 //#define THREADSAFE_I18N
 
+static mozilla::LazyLogModule gLog("nsDirectoryIndexStream");
+
 nsDirectoryIndexStream::nsDirectoryIndexStream()
     : mOffset(0), mStatus(NS_OK), mPos(0)
 {
-    if (! gLog)
-        gLog = PR_NewLogModule("nsDirectoryIndexStream");
-
     MOZ_LOG(gLog, LogLevel::Debug,
            ("nsDirectoryIndexStream[%p]: created", this));
 }
 
 static int compare(nsIFile* aElement1, nsIFile* aElement2, void* aData)
 {
     if (!NS_IsNativeUTF8()) {
         // don't check for errors, because we can't report them anyway
--- a/netwerk/base/nsInputStreamPump.cpp
+++ b/netwerk/base/nsInputStreamPump.cpp
@@ -19,17 +19,17 @@
 #include "nsNetCID.h"
 #include <algorithm>
 
 static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID);
 
 //
 // NSPR_LOG_MODULES=nsStreamPump:5
 //
-static PRLogModuleInfo *gStreamPumpLog = nullptr;
+static mozilla::LazyLogModule gStreamPumpLog("nsStreamPump");
 #undef LOG
 #define LOG(args) MOZ_LOG(gStreamPumpLog, mozilla::LogLevel::Debug, args)
 
 //-----------------------------------------------------------------------------
 // nsInputStreamPump methods
 //-----------------------------------------------------------------------------
 
 nsInputStreamPump::nsInputStreamPump()
@@ -40,18 +40,16 @@ nsInputStreamPump::nsInputStreamPump()
     , mSuspendCount(0)
     , mLoadFlags(LOAD_NORMAL)
     , mProcessingCallbacks(false)
     , mWaitingForInputStreamReady(false)
     , mCloseWhenDone(false)
     , mRetargeting(false)
     , mMonitor("nsInputStreamPump")
 {
-    if (!gStreamPumpLog)
-        gStreamPumpLog = PR_NewLogModule("nsStreamPump");
 }
 
 nsInputStreamPump::~nsInputStreamPump()
 {
 }
 
 nsresult
 nsInputStreamPump::Create(nsInputStreamPump  **result,
--- a/netwerk/base/nsLoadGroup.cpp
+++ b/netwerk/base/nsLoadGroup.cpp
@@ -33,18 +33,17 @@ using namespace mozilla::net;
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=LoadGroup:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables LogLevel::Debug level information and places all output in
 // the file nspr.log
 //
-static PRLogModuleInfo* gLoadGroupLog = nullptr;
-
+static LazyLogModule gLoadGroupLog("LoadGroup");
 #undef LOG
 #define LOG(args) MOZ_LOG(gLoadGroupLog, mozilla::LogLevel::Debug, args)
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class RequestMapEntry : public PLDHashEntryHdr
 {
 public:
@@ -112,21 +111,16 @@ nsLoadGroup::nsLoadGroup(nsISupports* ou
     , mPriority(PRIORITY_NORMAL)
     , mIsCanceling(false)
     , mDefaultLoadIsTimed(false)
     , mTimedRequests(0)
     , mCachedRequests(0)
     , mTimedNonCachedRequestsUntilOnEndPageLoad(0)
 {
     NS_INIT_AGGREGATED(outer);
-
-    // Initialize the global PRLogModule for nsILoadGroup logging
-    if (nullptr == gLoadGroupLog)
-        gLoadGroupLog = PR_NewLogModule("LoadGroup");
-
     LOG(("LOADGROUP [%x]: Created.\n", this));
 }
 
 nsLoadGroup::~nsLoadGroup()
 {
     DebugOnly<nsresult> rv = Cancel(NS_BINDING_ABORTED);
     NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed");
 
--- a/netwerk/base/nsPACMan.cpp
+++ b/netwerk/base/nsPACMan.cpp
@@ -20,18 +20,24 @@
 #ifdef MOZ_NUWA_PROCESS
 #include "ipc/Nuwa.h"
 #endif
 
 //-----------------------------------------------------------------------------
 using namespace mozilla;
 using namespace mozilla::net;
 
+namespace mozilla {
+namespace net {
+LazyLogModule gProxyLog("proxy");
+} // namespace net
+} // namespace mozilla
+
 #undef LOG
-#define LOG(args) MOZ_LOG(GetProxyLog(), mozilla::LogLevel::Debug, args)
+#define LOG(args) MOZ_LOG(mozilla::net::gProxyLog, mozilla::LogLevel::Debug, args)
 
 // The PAC thread does evaluations of both PAC files and
 // nsISystemProxySettings because they can both block the calling thread and we
 // don't want that on the main thread
 
 // Check to see if the underlying request was not an error page in the case of
 // a HTTP request.  For other types of channels, just return true.
 static bool
@@ -763,22 +769,8 @@ nsPACMan::Init(nsISystemProxySettings *s
 
   nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &nsPACMan::NamePACThread);
   // don't check return value as it is not a big deal for this to fail.
   mPACThread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
 
   return NS_OK;
 }
 
-namespace mozilla {
-namespace net {
-
-PRLogModuleInfo*
-GetProxyLog()
-{
-    static PRLogModuleInfo *sLog;
-    if (!sLog)
-        sLog = PR_NewLogModule("proxy");
-    return sLog;
-}
-
-} // namespace net
-} // namespace mozilla
--- a/netwerk/base/nsPACMan.h
+++ b/netwerk/base/nsPACMan.h
@@ -236,13 +236,13 @@ private:
   mozilla::TimeStamp           mScheduledReload;
   uint32_t                     mLoadFailureCount;
 
   bool                         mInProgress;
 };
 
 namespace mozilla {
 namespace net {
-PRLogModuleInfo* GetProxyLog();
+extern LazyLogModule gProxyLog;
 } // namespace net
 } // namespace mozilla
 
 #endif  // nsPACMan_h__
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -44,17 +44,17 @@ namespace mozilla {
   extern const char kProxyType_SOCKS5[];
   extern const char kProxyType_DIRECT[];
 } // namespace mozilla
 
 using namespace mozilla;
 
 #include "mozilla/Logging.h"
 #undef LOG
-#define LOG(args) MOZ_LOG(net::GetProxyLog(), mozilla::LogLevel::Debug, args)
+#define LOG(args) MOZ_LOG(net::gProxyLog, mozilla::LogLevel::Debug, args)
 
 //----------------------------------------------------------------------------
 
 #define PROXY_PREF_BRANCH  "network.proxy"
 #define PROXY_PREF(x)      PROXY_PREF_BRANCH "." x
 
 #define WPAD_URL "http://wpad/wpad.dat"
 
--- a/netwerk/base/nsRequestObserverProxy.cpp
+++ b/netwerk/base/nsRequestObserverProxy.cpp
@@ -8,17 +8,17 @@
 #include "nscore.h"
 #include "nsRequestObserverProxy.h"
 #include "nsIRequest.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Logging.h"
 
 using namespace mozilla;
 
-static PRLogModuleInfo *gRequestObserverProxyLog;
+static LazyLogModule gRequestObserverProxyLog("nsRequestObserverProxy");
 
 #undef LOG
 #define LOG(args) MOZ_LOG(gRequestObserverProxyLog, mozilla::LogLevel::Debug, args)
 
 //-----------------------------------------------------------------------------
 // nsARequestObserverEvent internal class...
 //-----------------------------------------------------------------------------
 
@@ -168,20 +168,16 @@ nsRequestObserverProxy::OnStopRequest(ns
 //-----------------------------------------------------------------------------
 // nsRequestObserverProxy::nsIRequestObserverProxy implementation...
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsRequestObserverProxy::Init(nsIRequestObserver *observer, nsISupports *context)
 {
     NS_ENSURE_ARG_POINTER(observer);
-
-    if (!gRequestObserverProxyLog)
-        gRequestObserverProxyLog = PR_NewLogModule("nsRequestObserverProxy");
-
     mObserver = new nsMainThreadPtrHolder<nsIRequestObserver>(observer);
     mContext = new nsMainThreadPtrHolder<nsISupports>(context);
 
     return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // nsRequestObserverProxy implementation...
--- a/netwerk/base/nsSecCheckWrapChannel.cpp
+++ b/netwerk/base/nsSecCheckWrapChannel.cpp
@@ -3,27 +3,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsContentSecurityManager.h"
 #include "nsSecCheckWrapChannel.h"
 #include "nsIForcePendingChannel.h"
 #include "nsCOMPtr.h"
 
-static PRLogModuleInfo*
-GetChannelWrapperLog()
-{
-  static PRLogModuleInfo* gChannelWrapperPRLog;
-  if (!gChannelWrapperPRLog) {
-    gChannelWrapperPRLog = PR_NewLogModule("ChannelWrapper");
-  }
-  return gChannelWrapperPRLog;
-}
-
-#define CHANNELWRAPPERLOG(args) MOZ_LOG(GetChannelWrapperLog(), mozilla::LogLevel::Debug, args)
+static mozilla::LazyLogModule gChannelWrapperLog("ChannelWrapper");
+#define CHANNELWRAPPERLOG(args) MOZ_LOG(gChannelWrapperLog, mozilla::LogLevel::Debug, args)
 
 NS_IMPL_ADDREF(nsSecCheckWrapChannelBase)
 NS_IMPL_RELEASE(nsSecCheckWrapChannelBase)
 
 NS_INTERFACE_MAP_BEGIN(nsSecCheckWrapChannelBase)
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIHttpChannel, mHttpChannel)
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIHttpChannelInternal, mHttpChannelInternal)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIHttpChannel)
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -24,18 +24,18 @@
 #include "mozilla/PodOperations.h"
 #include "mozilla/Telemetry.h"
 #include "nsThreadUtils.h"
 #include "nsIFile.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 
-PRLogModuleInfo *gSocketTransportLog = nullptr;
-PRLogModuleInfo *gUDPSocketLog = nullptr;
+LazyLogModule gSocketTransportLog("nsSocketTransport");
+LazyLogModule gUDPSocketLog("UDPSocket");
 
 nsSocketTransportService *gSocketTransportService = nullptr;
 PRThread                 *gSocketThread           = nullptr;
 
 #define SEND_BUFFER_PREF "network.tcp.sendbuffer"
 #define KEEPALIVE_ENABLED_PREF "network.tcp.keepalive.enabled"
 #define KEEPALIVE_IDLE_TIME_PREF "network.tcp.keepalive.idle_time"
 #define KEEPALIVE_RETRY_INTERVAL_PREF "network.tcp.keepalive.retry_interval"
@@ -106,19 +106,16 @@ nsSocketTransportService::nsSocketTransp
     , mKeepaliveRetryIntervalS(1)
     , mKeepaliveProbeCount(kDefaultTCPKeepCount)
     , mKeepaliveEnabledPref(false)
     , mServingPendingQueue(false)
     , mMaxTimePerPollIter(100)
     , mTelemetryEnabledPref(false)
     , mProbedMaxCount(false)
 {
-    gSocketTransportLog = PR_NewLogModule("nsSocketTransport");
-    gUDPSocketLog = PR_NewLogModule("UDPSocket");
-
     NS_ASSERTION(NS_IsMainThread(), "wrong thread");
 
     PR_CallOnce(&gMaxCountInitOnce, DiscoverMaxCount);
     mActiveList = (SocketContext *)
         moz_xmalloc(sizeof(SocketContext) * mActiveListSize);
     mIdleList = (SocketContext *)
         moz_xmalloc(sizeof(SocketContext) * mIdleListSize);
     mPollList = (PRPollDesc *)
--- a/netwerk/base/nsSocketTransportService2.h
+++ b/netwerk/base/nsSocketTransportService2.h
@@ -23,24 +23,24 @@
 class nsASocketHandler;
 struct PRPollDesc;
 
 //-----------------------------------------------------------------------------
 
 //
 // set NSPR_LOG_MODULES=nsSocketTransport:5
 //
-extern PRLogModuleInfo *gSocketTransportLog;
+extern mozilla::LazyLogModule gSocketTransportLog;
 #define SOCKET_LOG(args)     MOZ_LOG(gSocketTransportLog, mozilla::LogLevel::Debug, args)
 #define SOCKET_LOG_ENABLED() MOZ_LOG_TEST(gSocketTransportLog, mozilla::LogLevel::Debug)
 
 //
 // set NSPR_LOG_MODULES=UDPSocket:5
 //
-extern PRLogModuleInfo *gUDPSocketLog;
+extern mozilla::LazyLogModule gUDPSocketLog;
 #define UDPSOCKET_LOG(args)     MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args)
 #define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug)
 
 //-----------------------------------------------------------------------------
 
 #define NS_SOCKET_POLL_TIMEOUT PR_INTERVAL_NO_TIMEOUT
 
 //-----------------------------------------------------------------------------
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -35,17 +35,17 @@ nsIIDNService *nsStandardURL::gIDN = nul
 bool nsStandardURL::gInitialized = false;
 bool nsStandardURL::gEscapeUTF8 = true;
 bool nsStandardURL::gAlwaysEncodeInUTF8 = true;
 char nsStandardURL::gHostLimitDigits[] = { '/', '\\', '?', '#', 0 };
 
 //
 // setenv NSPR_LOG_MODULES nsStandardURL:5
 //
-static PRLogModuleInfo *gStandardURLLog;
+static mozilla::LazyLogModule gStandardURLLog("nsStandardURL");
 
 // The Chromium code defines its own LOG macro which we don't want
 #undef LOG
 #define LOG(args)     MOZ_LOG(gStandardURLLog, mozilla::LogLevel::Debug, args)
 #undef LOG_ENABLED
 #define LOG_ENABLED() MOZ_LOG_TEST(gStandardURLLog, mozilla::LogLevel::Debug)
 
 //----------------------------------------------------------------------------
@@ -247,19 +247,16 @@ nsStandardURL::nsStandardURL(bool aSuppo
     , mPort(-1)
     , mHostA(nullptr)
     , mHostEncoding(eEncoding_ASCII)
     , mSpecEncoding(eEncoding_Unknown)
     , mURLType(URLTYPE_STANDARD)
     , mMutable(true)
     , mSupportsFileURL(aSupportsFileURL)
 {
-    if (!gStandardURLLog)
-        gStandardURLLog = PR_NewLogModule("nsStandardURL");
-
     LOG(("Creating nsStandardURL @%p\n", this));
 
     if (!gInitialized) {
         gInitialized = true;
         InitGlobalObjects();
     }
 
     // default parser in case nsIStandardURL::Init is never called
--- a/netwerk/cache/nsCache.cpp
+++ b/netwerk/cache/nsCache.cpp
@@ -9,27 +9,17 @@
 #include "nsDependentSubstring.h"
 #include "nsString.h"
 
 
 /**
  * Cache Service Utility Functions
  */
 
-PRLogModuleInfo * gCacheLog = nullptr;
-
-
-void
-CacheLogInit()
-{
-    if (gCacheLog) return;
-    gCacheLog = PR_NewLogModule("cache");
-    NS_ASSERTION(gCacheLog, "\nfailed to allocate cache log.\n");
-}
-
+mozilla::LazyLogModule gCacheLog("cache");
 
 void
 CacheLogPrintPath(mozilla::LogLevel level, const char * format, nsIFile * item)
 {
     nsAutoCString path;
     nsresult rv = item->GetNativePath(path);
     if (NS_SUCCEEDED(rv)) {
         MOZ_LOG(gCacheLog, level, (format, path.get()));
--- a/netwerk/cache/nsCache.h
+++ b/netwerk/cache/nsCache.h
@@ -14,22 +14,20 @@
 #include "mozilla/Logging.h"
 #include "nsISupports.h"
 #include "nsIFile.h"
 #include "nsAString.h"
 #include "prtime.h"
 #include "nsError.h"
 
 // PR_LOG args = "format string", arg, arg, ...
-extern PRLogModuleInfo * gCacheLog;
-void   CacheLogInit();
+extern mozilla::LazyLogModule gCacheLog;
 void   CacheLogPrintPath(mozilla::LogLevel level,
                          const char *     format,
                          nsIFile *        item);
-#define CACHE_LOG_INIT()        CacheLogInit()
 #define CACHE_LOG_INFO(args)  MOZ_LOG(gCacheLog, mozilla::LogLevel::Info, args)
 #define CACHE_LOG_ERROR(args)   MOZ_LOG(gCacheLog, mozilla::LogLevel::Error, args)
 #define CACHE_LOG_WARNING(args) MOZ_LOG(gCacheLog, mozilla::LogLevel::Warning, args)
 #define CACHE_LOG_DEBUG(args)   MOZ_LOG(gCacheLog, mozilla::LogLevel::Debug, args)
 #define CACHE_LOG_PATH(level, format, item) \
                                 CacheLogPrintPath(level, format, item)
 
 
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1124,18 +1124,16 @@ nsCacheService::Init()
     NS_ASSERTION(!mInitialized, "nsCacheService already initialized.");
     if (mInitialized)
         return NS_ERROR_ALREADY_INITIALIZED;
 
     if (mozilla::net::IsNeckoChild()) {
         return NS_ERROR_UNEXPECTED;
     }
 
-    CACHE_LOG_INIT();
-
     nsresult rv;
 
     mStorageService = do_GetService("@mozilla.org/storage/service;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = NS_NewNamedThread("Cache I/O",
                            getter_AddRefs(mCacheIOThread));
     if (NS_FAILED(rv)) {
--- a/netwerk/cache2/CacheLog.cpp
+++ b/netwerk/cache2/CacheLog.cpp
@@ -11,18 +11,12 @@ namespace net {
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=cache2:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables LogLevel::Debug level information and places all output in
 // the file nspr.log
-PRLogModuleInfo* GetCache2Log()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("cache2");
-  return sLog;
-}
+LazyLogModule gCache2Log("cache2");
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/cache2/CacheLog.h
+++ b/netwerk/cache2/CacheLog.h
@@ -5,16 +5,16 @@
 #ifndef Cache2Log__h__
 #define Cache2Log__h__
 
 #include "mozilla/Logging.h"
 
 namespace mozilla {
 namespace net {
 
-extern PRLogModuleInfo* GetCache2Log();
-#define LOG(x)  MOZ_LOG(GetCache2Log(), mozilla::LogLevel::Debug, x)
-#define LOG_ENABLED() MOZ_LOG_TEST(GetCache2Log(), mozilla::LogLevel::Debug)
+extern LazyLogModule gCache2Log;
+#define LOG(x)  MOZ_LOG(gCache2Log, mozilla::LogLevel::Debug, x)
+#define LOG_ENABLED() MOZ_LOG_TEST(gCache2Log, mozilla::LogLevel::Debug)
 
 } // namespace net
 } // namespace mozilla
 
 #endif
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -180,132 +180,125 @@ struct nsListIter
 //
 #include "mozilla/Logging.h"
 #endif
 
 // define logging macros for convenience
 #define SET_COOKIE true
 #define GET_COOKIE false
 
-static PRLogModuleInfo *
-GetCookieLog()
-{
-  static PRLogModuleInfo *sCookieLog;
-  if (!sCookieLog)
-    sCookieLog = PR_NewLogModule("cookie");
-  return sCookieLog;
-}
+static LazyLogModule gCookieLog("cookie");
 
 #define COOKIE_LOGFAILURE(a, b, c, d)    LogFailure(a, b, c, d)
 #define COOKIE_LOGSUCCESS(a, b, c, d, e) LogSuccess(a, b, c, d, e)
 
 #define COOKIE_LOGEVICTED(a, details)          \
   PR_BEGIN_MACRO                               \
-  if (MOZ_LOG_TEST(GetCookieLog(), LogLevel::Debug))  \
+  if (MOZ_LOG_TEST(gCookieLog, LogLevel::Debug))  \
       LogEvicted(a, details);                  \
   PR_END_MACRO
 
 #define COOKIE_LOGSTRING(lvl, fmt)   \
   PR_BEGIN_MACRO                     \
-    MOZ_LOG(GetCookieLog(), lvl, fmt);  \
-    MOZ_LOG(GetCookieLog(), lvl, ("\n")); \
+    MOZ_LOG(gCookieLog, lvl, fmt);  \
+    MOZ_LOG(gCookieLog, lvl, ("\n")); \
   PR_END_MACRO
 
 static void
 LogFailure(bool aSetCookie, nsIURI *aHostURI, const char *aCookieString, const char *aReason)
 {
   // if logging isn't enabled, return now to save cycles
-  if (!MOZ_LOG_TEST(GetCookieLog(), LogLevel::Warning))
+  if (!MOZ_LOG_TEST(gCookieLog, LogLevel::Warning))
     return;
 
   nsAutoCString spec;
   if (aHostURI)
     aHostURI->GetAsciiSpec(spec);
 
-  MOZ_LOG(GetCookieLog(), LogLevel::Warning,
+  MOZ_LOG(gCookieLog, LogLevel::Warning,
     ("===== %s =====\n", aSetCookie ? "COOKIE NOT ACCEPTED" : "COOKIE NOT SENT"));
-  MOZ_LOG(GetCookieLog(), LogLevel::Warning,("request URL: %s\n", spec.get()));
+  MOZ_LOG(gCookieLog, LogLevel::Warning,("request URL: %s\n", spec.get()));
   if (aSetCookie)
-    MOZ_LOG(GetCookieLog(), LogLevel::Warning,("cookie string: %s\n", aCookieString));
+    MOZ_LOG(gCookieLog, LogLevel::Warning,("cookie string: %s\n", aCookieString));
 
   PRExplodedTime explodedTime;
   PR_ExplodeTime(PR_Now(), PR_GMTParameters, &explodedTime);
   char timeString[40];
   PR_FormatTimeUSEnglish(timeString, 40, "%c GMT", &explodedTime);
 
-  MOZ_LOG(GetCookieLog(), LogLevel::Warning,("current time: %s", timeString));
-  MOZ_LOG(GetCookieLog(), LogLevel::Warning,("rejected because %s\n", aReason));
-  MOZ_LOG(GetCookieLog(), LogLevel::Warning,("\n"));
+  MOZ_LOG(gCookieLog, LogLevel::Warning,("current time: %s", timeString));
+  MOZ_LOG(gCookieLog, LogLevel::Warning,("rejected because %s\n", aReason));
+  MOZ_LOG(gCookieLog, LogLevel::Warning,("\n"));
 }
 
 static void
 LogCookie(nsCookie *aCookie)
 {
   PRExplodedTime explodedTime;
   PR_ExplodeTime(PR_Now(), PR_GMTParameters, &explodedTime);
   char timeString[40];
   PR_FormatTimeUSEnglish(timeString, 40, "%c GMT", &explodedTime);
 
-  MOZ_LOG(GetCookieLog(), LogLevel::Debug,("current time: %s", timeString));
+  MOZ_LOG(gCookieLog, LogLevel::Debug,("current time: %s", timeString));
 
   if (aCookie) {
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("----------------\n"));
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("name: %s\n", aCookie->Name().get()));
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("value: %s\n", aCookie->Value().get()));
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("%s: %s\n", aCookie->IsDomain() ? "domain" : "host", aCookie->Host().get()));
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("path: %s\n", aCookie->Path().get()));
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("----------------\n"));
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("name: %s\n", aCookie->Name().get()));
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("value: %s\n", aCookie->Value().get()));
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("%s: %s\n", aCookie->IsDomain() ? "domain" : "host", aCookie->Host().get()));
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("path: %s\n", aCookie->Path().get()));
 
     PR_ExplodeTime(aCookie->Expiry() * int64_t(PR_USEC_PER_SEC),
                    PR_GMTParameters, &explodedTime);
     PR_FormatTimeUSEnglish(timeString, 40, "%c GMT", &explodedTime);
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,
+    MOZ_LOG(gCookieLog, LogLevel::Debug,
       ("expires: %s%s", timeString, aCookie->IsSession() ? " (at end of session)" : ""));
 
     PR_ExplodeTime(aCookie->CreationTime(), PR_GMTParameters, &explodedTime);
     PR_FormatTimeUSEnglish(timeString, 40, "%c GMT", &explodedTime);
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("created: %s", timeString));
-
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("is secure: %s\n", aCookie->IsSecure() ? "true" : "false"));
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("is httpOnly: %s\n", aCookie->IsHttpOnly() ? "true" : "false"));
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("created: %s", timeString));
+
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("is secure: %s\n", aCookie->IsSecure() ? "true" : "false"));
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("is httpOnly: %s\n", aCookie->IsHttpOnly() ? "true" : "false"));
   }
 }
 
 static void
 LogSuccess(bool aSetCookie, nsIURI *aHostURI, const char *aCookieString, nsCookie *aCookie, bool aReplacing)
 {
   // if logging isn't enabled, return now to save cycles
-  if (!MOZ_LOG_TEST(GetCookieLog(), LogLevel::Debug)) {
+  if (!MOZ_LOG_TEST(gCookieLog, LogLevel::Debug)) {
     return;
   }
 
   nsAutoCString spec;
   if (aHostURI)
     aHostURI->GetAsciiSpec(spec);
 
-  MOZ_LOG(GetCookieLog(), LogLevel::Debug,
+  MOZ_LOG(gCookieLog, LogLevel::Debug,
     ("===== %s =====\n", aSetCookie ? "COOKIE ACCEPTED" : "COOKIE SENT"));
-  MOZ_LOG(GetCookieLog(), LogLevel::Debug,("request URL: %s\n", spec.get()));
-  MOZ_LOG(GetCookieLog(), LogLevel::Debug,("cookie string: %s\n", aCookieString));
+  MOZ_LOG(gCookieLog, LogLevel::Debug,("request URL: %s\n", spec.get()));
+  MOZ_LOG(gCookieLog, LogLevel::Debug,("cookie string: %s\n", aCookieString));
   if (aSetCookie)
-    MOZ_LOG(GetCookieLog(), LogLevel::Debug,("replaces existing cookie: %s\n", aReplacing ? "true" : "false"));
+    MOZ_LOG(gCookieLog, LogLevel::Debug,("replaces existing cookie: %s\n", aReplacing ? "true" : "false"));
 
   LogCookie(aCookie);
 
-  MOZ_LOG(GetCookieLog(), LogLevel::Debug,("\n"));
+  MOZ_LOG(gCookieLog, LogLevel::Debug,("\n"));
 }
 
 static void
 LogEvicted(nsCookie *aCookie, const char* details)
 {
-  MOZ_LOG(GetCookieLog(), LogLevel::Debug,("===== COOKIE EVICTED =====\n"));
-  MOZ_LOG(GetCookieLog(), LogLevel::Debug,("%s\n", details));
+  MOZ_LOG(gCookieLog, LogLevel::Debug,("===== COOKIE EVICTED =====\n"));
+  MOZ_LOG(gCookieLog, LogLevel::Debug,("%s\n", details));
 
   LogCookie(aCookie);
 
-  MOZ_LOG(GetCookieLog(), LogLevel::Debug,("\n"));
+  MOZ_LOG(gCookieLog, LogLevel::Debug,("\n"));
 }
 
 // inline wrappers to make passing in nsAFlatCStrings easier
 static inline void
 LogFailure(bool aSetCookie, nsIURI *aHostURI, const nsAFlatCString &aCookieString, const char *aReason)
 {
   LogFailure(aSetCookie, aHostURI, aCookieString.get(), aReason);
 }
@@ -341,17 +334,17 @@ class DBListenerErrorHandler : public mo
 protected:
   explicit DBListenerErrorHandler(DBState* dbState) : mDBState(dbState) { }
   RefPtr<DBState> mDBState;
   virtual const char *GetOpType() = 0;
 
 public:
   NS_IMETHOD HandleError(mozIStorageError* aError) override
   {
-    if (MOZ_LOG_TEST(GetCookieLog(), LogLevel::Warning)) {
+    if (MOZ_LOG_TEST(gCookieLog, LogLevel::Warning)) {
       int32_t result = -1;
       aError->GetResult(&result);
 
       nsAutoCString message;
       aError->GetMessage(message);
       COOKIE_LOGSTRING(LogLevel::Warning,
         ("DBListenerErrorHandler::HandleError(): Error %d occurred while "
          "performing operation '%s' with message '%s'; rebuilding database.",
--- a/netwerk/dns/GetAddrInfo.cpp
+++ b/netwerk/dns/GetAddrInfo.cpp
@@ -18,36 +18,37 @@
 #include <algorithm>
 #include "prerror.h"
 
 #if defined(ANDROID) && ANDROID_VERSION > 19
 #include <resolv_netid.h>
 #endif
 
 #include "mozilla/Logging.h"
-static PRLogModuleInfo *gGetAddrInfoLog = PR_NewLogModule("GetAddrInfo");
-#define LOG(msg, ...) \
-  MOZ_LOG(gGetAddrInfoLog, LogLevel::Debug, ("[DNS]: " msg, ##__VA_ARGS__))
-#define LOG_WARNING(msg, ...) \
-  MOZ_LOG(gGetAddrInfoLog, LogLevel::Warning, ("[DNS]: " msg, ##__VA_ARGS__))
 
 #if DNSQUERY_AVAILABLE
 // There is a bug in windns.h where the type of parameter ppQueryResultsSet for
 // DnsQuery_A is dependent on UNICODE being set. It should *always* be
 // PDNS_RECORDA, but if UNICODE is set it is PDNS_RECORDW. To get around this
 // we make sure that UNICODE is unset.
 #undef UNICODE
 #include <ws2tcpip.h>
 #undef GetAddrInfo
 #include <windns.h>
 #endif
 
 namespace mozilla {
 namespace net {
 
+static LazyLogModule gGetAddrInfoLog("GetAddrInfo");
+#define LOG(msg, ...) \
+  MOZ_LOG(gGetAddrInfoLog, LogLevel::Debug, ("[DNS]: " msg, ##__VA_ARGS__))
+#define LOG_WARNING(msg, ...) \
+  MOZ_LOG(gGetAddrInfoLog, LogLevel::Warning, ("[DNS]: " msg, ##__VA_ARGS__))
+
 #if DNSQUERY_AVAILABLE
 ////////////////////////////
 // WINDOWS IMPLEMENTATION //
 ////////////////////////////
 
 // Ensure consistency of PR_* and AF_* constants to allow for legacy usage of
 // PR_* constants with this API.
 static_assert(PR_AF_INET == AF_INET && PR_AF_INET6 == AF_INET6
--- a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp
+++ b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp
@@ -20,30 +20,25 @@
 #include "nsNetCID.h"
 #include "nsSocketTransportService2.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOMCID.h"
 #include "private/pprio.h"
 
 #include "nsASocketHandler.h"
 
-inline PRLogModuleInfo*
-GetOperatorLog()
-{
-  static PRLogModuleInfo* log = PR_NewLogModule("MDNSResponderOperator");
-  return log;
-}
-#undef LOG_I
-#define LOG_I(...) MOZ_LOG(GetOperatorLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
-#undef LOG_E
-#define LOG_E(...) MOZ_LOG(GetOperatorLog(), mozilla::LogLevel::Error, (__VA_ARGS__))
-
 namespace mozilla {
 namespace net {
 
+static LazyLogModule gMDNSLog("MDNSResponderOperator");
+#undef LOG_I
+#define LOG_I(...) MOZ_LOG(mozilla::net::gMDNSLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
+#undef LOG_E
+#define LOG_E(...) MOZ_LOG(mozilla::net::gMDNSLog, mozilla::LogLevel::Error, (__VA_ARGS__))
+
 class MDNSResponderOperator::ServiceWatcher final
   : public nsASocketHandler
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   // nsASocketHandler methods
   virtual void OnSocketReady(PRFileDesc* fd, int16_t outFlags) override
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -63,17 +63,17 @@ static const unsigned int NEGATIVE_RECOR
 #define HighThreadThreshold     MAX_RESOLVER_THREADS_FOR_ANY_PRIORITY
 #define LongIdleTimeoutSeconds  300           // for threads 1 -> HighThreadThreshold
 #define ShortIdleTimeoutSeconds 60            // for threads HighThreadThreshold+1 -> MAX_RESOLVER_THREADS
 
 PR_STATIC_ASSERT (HighThreadThreshold <= MAX_RESOLVER_THREADS);
 
 //----------------------------------------------------------------------------
 
-static PRLogModuleInfo *gHostResolverLog = nullptr;
+static LazyLogModule gHostResolverLog("nsHostResolver");
 #define LOG(args) MOZ_LOG(gHostResolverLog, mozilla::LogLevel::Debug, args)
 
 #define LOG_HOST(host, interface) host,                                        \
                  (interface && interface[0] != '\0') ? " on interface " : "",  \
                  (interface && interface[0] != '\0') ? interface : ""
 
 //----------------------------------------------------------------------------
 
@@ -1453,19 +1453,16 @@ nsHostResolver::ThreadFunc(void *arg)
 }
 
 nsresult
 nsHostResolver::Create(uint32_t maxCacheEntries,
                        uint32_t defaultCacheEntryLifetime,
                        uint32_t defaultGracePeriod,
                        nsHostResolver **result)
 {
-    if (!gHostResolverLog)
-        gHostResolverLog = PR_NewLogModule("nsHostResolver");
-
     nsHostResolver *res = new nsHostResolver(maxCacheEntries, defaultCacheEntryLifetime,
                                              defaultGracePeriod);
     NS_ADDREF(res);
 
     nsresult rv = res->Init();
     if (NS_FAILED(rv))
         NS_RELEASE(res);
 
--- a/netwerk/protocol/ftp/nsFTPChannel.cpp
+++ b/netwerk/protocol/ftp/nsFTPChannel.cpp
@@ -5,17 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsFTPChannel.h"
 #include "nsFtpConnectionThread.h"  // defines nsFtpState
 
 #include "nsThreadUtils.h"
 #include "mozilla/Attributes.h"
 
-extern PRLogModuleInfo* gFTPLog;
+using namespace mozilla;
+using namespace mozilla::net;
+extern LazyLogModule gFTPLog;
 
 // There are two transport connections established for an 
 // ftp connection. One is used for the command channel , and
 // the other for the data channel. The command channel is the first
 // connection made and is used to negotiate the second, data, channel.
 // The data channel is driven by the command channel and is either
 // initiated by the server (PORT command) or by the client (PASV command).
 // Client initiation is the most common case and is attempted first.
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
@@ -42,22 +42,23 @@
 #include "nsIURI.h"
 #include "nsILoadInfo.h"
 #include "nsNullPrincipal.h"
 
 #ifdef MOZ_WIDGET_GONK
 #include "NetStatistics.h"
 #endif
 
-extern PRLogModuleInfo* gFTPLog;
+using namespace mozilla;
+using namespace mozilla::net;
+
+extern LazyLogModule gFTPLog;
 #define LOG(args)         MOZ_LOG(gFTPLog, mozilla::LogLevel::Debug, args)
 #define LOG_INFO(args)  MOZ_LOG(gFTPLog, mozilla::LogLevel::Info, args)
 
-using namespace mozilla::net;
-
 // remove FTP parameters (starting with ";") from the path
 static void
 removeParamsFromPath(nsCString& path)
 {
   int32_t index = path.FindChar(';');
   if (index >= 0) {
     path.SetLength(index);
   }
--- a/netwerk/protocol/ftp/nsFtpControlConnection.cpp
+++ b/netwerk/protocol/ftp/nsFtpControlConnection.cpp
@@ -10,17 +10,20 @@
 #include "nsIInputStream.h"
 #include "nsISocketTransportService.h"
 #include "nsISocketTransport.h"
 #include "nsThreadUtils.h"
 #include "nsIOutputStream.h"
 #include "nsNetCID.h"
 #include <algorithm>
 
-extern PRLogModuleInfo* gFTPLog;
+using namespace mozilla;
+using namespace mozilla::net;
+
+extern LazyLogModule gFTPLog;
 #define LOG(args)         MOZ_LOG(gFTPLog, mozilla::LogLevel::Debug, args)
 #define LOG_INFO(args)  MOZ_LOG(gFTPLog, mozilla::LogLevel::Info, args)
 
 //
 // nsFtpControlConnection implementation ...
 //
 
 NS_IMPL_ISUPPORTS(nsFtpControlConnection, nsIInputStreamCallback)
--- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
+++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
@@ -40,17 +40,17 @@ using namespace mozilla::net;
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsFtp:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables LogLevel::Debug level information and places all output in
 // the file nspr.log
 //
-PRLogModuleInfo* gFTPLog = nullptr;
+LazyLogModule gFTPLog("nsFtp");
 #undef LOG
 #define LOG(args) MOZ_LOG(gFTPLog, mozilla::LogLevel::Debug, args)
 
 //-----------------------------------------------------------------------------
 
 #define IDLE_TIMEOUT_PREF     "network.ftp.idleConnectionTimeout"
 #define IDLE_CONNECTION_LIMIT 8 /* TODO pref me */
 
@@ -62,19 +62,16 @@ nsFtpProtocolHandler *gFtpHandler = null
 //-----------------------------------------------------------------------------
 
 nsFtpProtocolHandler::nsFtpProtocolHandler()
     : mIdleTimeout(-1)
     , mSessionId(0)
     , mControlQoSBits(0x00)
     , mDataQoSBits(0x00)
 {
-    if (!gFTPLog)
-        gFTPLog = PR_NewLogModule("nsFtp");
-
     LOG(("FTP:creating handler @%x\n", this));
 
     gFtpHandler = this;
 }
 
 nsFtpProtocolHandler::~nsFtpProtocolHandler()
 {
     LOG(("FTP:destroying handler @%x\n", this));
--- a/netwerk/protocol/ftp/nsFtpProtocolHandler.h
+++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.h
@@ -77,11 +77,11 @@ private:
     uint8_t mControlQoSBits;
     uint8_t mDataQoSBits;
 };
 
 //-----------------------------------------------------------------------------
 
 extern nsFtpProtocolHandler *gFtpHandler;
 
-extern PRLogModuleInfo* gFTPLog;
+extern mozilla::LazyLogModule gFTPLog;
 
 #endif // !nsFtpProtocolHandler_h__
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -38,26 +38,26 @@
 #include "nsThreadUtils.h"
 #include "PrivateBrowsingChannel.h"
 #include "mozilla/net/DNS.h"
 #include "nsITimedChannel.h"
 #include "nsIHttpChannel.h"
 #include "nsISecurityConsoleMessage.h"
 #include "nsCOMArray.h"
 
-extern PRLogModuleInfo *gHttpLog;
 class nsPerformance;
 class nsISecurityConsoleMessage;
 class nsIPrincipal;
 
 namespace mozilla {
 
 class LogCollector;
 
 namespace net {
+extern mozilla::LazyLogModule gHttpLog;
 
 /*
  * This class is a partial implementation of nsIHttpChannel.  It contains code
  * shared by nsHttpChannel and HttpChannelChild.
  * - Note that this class has nothing to do with nsBaseChannel, which is an
  *   earlier effort at a base class for channels that somehow never made it all
  *   the way to the HTTP channel.
  */
--- a/netwerk/protocol/http/HttpLog.h
+++ b/netwerk/protocol/http/HttpLog.h
@@ -29,26 +29,30 @@
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsHttp:5
 //    set NSPR_LOG_FILE=http.log
 //
 // this enables LogLevel::Debug level information and places all output in
 // the file http.log
 //
-extern PRLogModuleInfo *gHttpLog;
+namespace mozilla {
+namespace net {
+extern LazyLogModule gHttpLog;
+}
+}
 
 // http logging
-#define LOG1(args) MOZ_LOG(gHttpLog, mozilla::LogLevel::Error, args)
-#define LOG2(args) MOZ_LOG(gHttpLog, mozilla::LogLevel::Warning, args)
-#define LOG3(args) MOZ_LOG(gHttpLog, mozilla::LogLevel::Info, args)
-#define LOG4(args) MOZ_LOG(gHttpLog, mozilla::LogLevel::Debug, args)
-#define LOG5(args) MOZ_LOG(gHttpLog, mozilla::LogLevel::Verbose, args)
+#define LOG1(args) MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Error, args)
+#define LOG2(args) MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Warning, args)
+#define LOG3(args) MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Info, args)
+#define LOG4(args) MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Debug, args)
+#define LOG5(args) MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Verbose, args)
 #define LOG(args) LOG4(args)
 
-#define LOG1_ENABLED() MOZ_LOG_TEST(gHttpLog, mozilla::LogLevel::Error)
-#define LOG2_ENABLED() MOZ_LOG_TEST(gHttpLog, mozilla::LogLevel::Warning)
-#define LOG3_ENABLED() MOZ_LOG_TEST(gHttpLog, mozilla::LogLevel::Info)
-#define LOG4_ENABLED() MOZ_LOG_TEST(gHttpLog, mozilla::LogLevel::Debug)
-#define LOG5_ENABLED() MOZ_LOG_TEST(gHttpLog, mozilla::LogLevel::Verbose)
+#define LOG1_ENABLED() MOZ_LOG_TEST(mozilla::net::gHttpLog, mozilla::LogLevel::Error)
+#define LOG2_ENABLED() MOZ_LOG_TEST(mozilla::net::gHttpLog, mozilla::LogLevel::Warning)
+#define LOG3_ENABLED() MOZ_LOG_TEST(mozilla::net::gHttpLog, mozilla::LogLevel::Info)
+#define LOG4_ENABLED() MOZ_LOG_TEST(mozilla::net::gHttpLog, mozilla::LogLevel::Debug)
+#define LOG5_ENABLED() MOZ_LOG_TEST(mozilla::net::gHttpLog, mozilla::LogLevel::Verbose)
 #define LOG_ENABLED() LOG4_ENABLED()
 
 #endif // HttpLog_h__
--- a/netwerk/protocol/http/PackagedAppService.cpp
+++ b/netwerk/protocol/http/PackagedAppService.cpp
@@ -18,18 +18,17 @@
 #include "nsIHttpHeaderVisitor.h"
 #include "mozilla/LoadContext.h"
 #include "nsIInstallPackagedWebapp.h"
 
 namespace mozilla {
 namespace net {
 
 static PackagedAppService *gPackagedAppService = nullptr;
-
-static PRLogModuleInfo *gPASLog = nullptr;
+static LazyLogModule gPASLog("PackagedAppService");
 #undef LOG
 #define LOG(args) MOZ_LOG(gPASLog, mozilla::LogLevel::Debug, args)
 
 NS_IMPL_ISUPPORTS(PackagedAppService, nsIPackagedAppService)
 
 NS_IMPL_ISUPPORTS(PackagedAppService::CacheEntryWriter, nsIStreamListener)
 
 static void
@@ -1038,17 +1037,16 @@ PackagedAppService::PackagedAppDownloade
   }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 PackagedAppService::PackagedAppService()
 {
   gPackagedAppService = this;
-  gPASLog = PR_NewLogModule("PackagedAppService");
   LOG(("[%p] Created PackagedAppService\n", this));
 }
 
 PackagedAppService::~PackagedAppService()
 {
   LOG(("[%p] Destroying PackagedAppService\n", this));
   gPackagedAppService = nullptr;
 }
--- a/netwerk/protocol/http/nsHttp.cpp
+++ b/netwerk/protocol/http/nsHttp.cpp
@@ -8,18 +8,16 @@
 #include "HttpLog.h"
 
 #include "nsHttp.h"
 #include "PLDHashTable.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/HashFunctions.h"
 #include "nsCRT.h"
 
-PRLogModuleInfo *gHttpLog = nullptr;
-
 namespace mozilla {
 namespace net {
 
 // define storage for all atoms
 #define HTTP_ATOM(_name, _value) nsHttpAtom nsHttp::_name = { _value };
 #include "nsHttpAtomList.h"
 #undef HTTP_ATOM
 
--- a/netwerk/protocol/http/nsHttpConnectionInfo.h
+++ b/netwerk/protocol/http/nsHttpConnectionInfo.h
@@ -9,33 +9,33 @@
 
 #include "nsHttp.h"
 #include "nsProxyInfo.h"
 #include "nsCOMPtr.h"
 #include "nsStringFwd.h"
 #include "mozilla/Logging.h"
 #include "ARefBase.h"
 
-extern PRLogModuleInfo *gHttpLog;
-
 //-----------------------------------------------------------------------------
 // nsHttpConnectionInfo - holds the properties of a connection
 //-----------------------------------------------------------------------------
 
 // http:// uris through a proxy will all share the same CI, because they can
 // all use the same connection. (modulo pb and anonymous flags). They just use
 // the proxy as the origin host name.
 // however, https:// uris tunnel through the proxy so they will have different
 // CIs - the CI reflects both the proxy and the origin.
 // however, proxy conenctions made with http/2 (or spdy) can tunnel to the origin
 // and multiplex non tunneled transactions at the same time, so they have a
 // special wildcard CI that accepts all origins through that proxy.
 
 namespace mozilla { namespace net {
 
+extern LazyLogModule gHttpLog;
+
 class nsHttpConnectionInfo: public ARefBase
 {
 public:
     nsHttpConnectionInfo(const nsACString &originHost,
                          int32_t originPort,
                          const nsACString &npnToken,
                          const nsACString &username,
                          nsProxyInfo *proxyInfo,
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -98,16 +98,18 @@ extern PRThread *gSocketThread;
 
 #define NS_HTTP_PROTOCOL_FLAGS (URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE)
 
 //-----------------------------------------------------------------------------
 
 namespace mozilla {
 namespace net {
 
+LazyLogModule gHttpLog("nsHttp");
+
 static nsresult
 NewURI(const nsACString &aSpec,
        const char *aCharset,
        nsIURI *aBaseURI,
        int32_t aDefaultPort,
        nsIURI **aURI)
 {
     nsStandardURL *url = new nsStandardURL();
@@ -211,18 +213,16 @@ nsHttpHandler::nsHttpHandler()
     , mCriticalRequestPrioritization(true)
     , mTCPKeepaliveShortLivedEnabled(false)
     , mTCPKeepaliveShortLivedTimeS(60)
     , mTCPKeepaliveShortLivedIdleTimeS(10)
     , mTCPKeepaliveLongLivedEnabled(false)
     , mTCPKeepaliveLongLivedIdleTimeS(600)
     , mEnforceH1Framing(FRAMECHECK_BARELY)
 {
-    gHttpLog = PR_NewLogModule("nsHttp");
-
     LOG(("Creating nsHttpHandler [this=%p].\n", this));
 
     RegisterStrongMemoryReporter(new SpdyZlibReporter());
 
     MOZ_ASSERT(!gHttpHandler, "HTTP handler already created!");
     gHttpHandler = this;
 }
 
--- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp
+++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp
@@ -17,17 +17,17 @@
 #include "nsEscape.h"
 
 using mozilla::dom::ContentParent;
 
 namespace mozilla {
 
 // Log module for Substituting Protocol logging. We keep the pre-existing module
 // name of "nsResProtocol" to avoid disruption.
-static PRLogModuleInfo *gResLog;
+static LazyLogModule gResLog("nsResProtocol");
 
 static NS_DEFINE_CID(kSubstitutingURLCID, NS_SUBSTITUTINGURL_CID);
 
 //---------------------------------------------------------------------------------
 // SubstitutingURL : overrides nsStandardURL::GetFile to provide nsIFile resolution
 //---------------------------------------------------------------------------------
 
 nsresult
@@ -100,20 +100,16 @@ SubstitutingProtocolHandler::Substitutin
 }
 
 void
 SubstitutingProtocolHandler::ConstructInternal()
 {
   nsresult rv;
   mIOService = do_GetIOService(&rv);
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv) && mIOService);
-
-  if (!gResLog) {
-    gResLog = PR_NewLogModule("nsResProtocol");
-  }
 }
 
 //
 // IPC marshalling.
 //
 
 struct EnumerateSubstitutionArg
 {
--- a/netwerk/protocol/rtsp/controller/RtspController.cpp
+++ b/netwerk/protocol/rtsp/controller/RtspController.cpp
@@ -37,22 +37,21 @@
 
 #include "plbase64.h"
 #include "prmem.h"
 #include "prnetdb.h"
 #include "zlib.h"
 #include <algorithm>
 #include "nsDebug.h"
 
-extern PRLogModuleInfo* gRtspLog;
-#undef LOG
-#define LOG(args) MOZ_LOG(gRtspLog, mozilla::LogLevel::Debug, args)
-
 namespace mozilla {
 namespace net {
+extern LazyLogModule gRtspLog;
+#undef LOG
+#define LOG(args) MOZ_LOG(mozilla::net::gRtspLog, mozilla::LogLevel::Debug, args)
 
 //-----------------------------------------------------------------------------
 // RtspController
 //-----------------------------------------------------------------------------
 NS_IMPL_ISUPPORTS(RtspController,
                   nsIStreamingProtocolController)
 
 RtspController::RtspController(nsIChannel *channel)
--- a/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp
+++ b/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp
@@ -10,28 +10,28 @@
 #include "mozilla/net/NeckoChild.h"
 #include "nsITabChild.h"
 #include "nsILoadContext.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "nsStringStream.h"
 #include "mozilla/Logging.h"
 
-PRLogModuleInfo* gRtspChildLog = nullptr;
-#undef LOG
-#define LOG(args) MOZ_LOG(gRtspChildLog, mozilla::LogLevel::Debug, args)
-
 const uint32_t kRtspTotalTracks = 2;
 const unsigned long kRtspCommandDelayMs = 200;
 
 using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace net {
 
+static LazyLogModule gRtspChildLog("nsRtspChild");
+#undef LOG
+#define LOG(args) MOZ_LOG(mozilla::net::gRtspChildLog, mozilla::LogLevel::Debug, args)
+
 NS_IMPL_ADDREF(RtspControllerChild)
 
 NS_IMETHODIMP_(nsrefcnt) RtspControllerChild::Release()
 {
   NS_PRECONDITION(0 != mRefCnt, "dup release");
   // Enable this to find non-threadsafe destructors:
   // NS_ASSERT_OWNINGTHREAD(RtspControllerChild);
   --mRefCnt;
@@ -64,18 +64,16 @@ RtspControllerChild::RtspControllerChild
   , mIPCAllowed(false)
   , mChannel(channel)
   , mTotalTracks(0)
   , mSuspendCount(0)
   , mTimerLock("RtspControllerChild.mTimerLock")
   , mPlayTimer(nullptr)
   , mPauseTimer(nullptr)
 {
-  if (!gRtspChildLog)
-    gRtspChildLog = PR_NewLogModule("nsRtspChild");
   AddIPDLReference();
   gNeckoChild->SendPRtspControllerConstructor(this);
 }
 
 RtspControllerChild::~RtspControllerChild()
 {
   LOG(("RtspControllerChild::~RtspControllerChild()"));
 }
--- a/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp
+++ b/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp
@@ -11,32 +11,32 @@
 #include "nsProxyRelease.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/unused.h"
 #include "mozilla/Logging.h"
 
 #include <sys/types.h>
 
-PRLogModuleInfo* gRtspLog;
-#undef LOG
-#define LOG(args) MOZ_LOG(gRtspLog, mozilla::LogLevel::Debug, args)
-
 #define SEND_DISCONNECT_IF_ERROR(rv)                         \
   if (NS_FAILED(rv) && mIPCOpen && mTotalTracks > 0ul) {     \
     for (uint32_t i = 0; i < mTotalTracks; i++) {            \
       Unused << SendOnDisconnected(i, rv);                   \
     }                                                        \
   }
 
 using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace net {
 
+LazyLogModule gRtspLog("nsRtsp");
+#undef LOG
+#define LOG(args) MOZ_LOG(mozilla::net::gRtspLog, mozilla::LogLevel::Debug, args)
+
 void
 RtspControllerParent::Destroy()
 {
   // If we're being destroyed on a non-main thread, we AddRef again and use a
   // proxy to release the RtspControllerParent on the main thread, where the
   // RtspControllerParent is deleted. This ensures we only delete the
   // RtspControllerParent on the main thread.
   if (!NS_IsMainThread()) {
@@ -56,18 +56,16 @@ NS_IMPL_ADDREF(RtspControllerParent)
 NS_IMPL_RELEASE_WITH_DESTROY(RtspControllerParent, Destroy())
 NS_IMPL_QUERY_INTERFACE(RtspControllerParent,
                         nsIStreamingProtocolListener)
 
 RtspControllerParent::RtspControllerParent()
   : mIPCOpen(true)
   , mTotalTracks(0)
 {
-  if (!gRtspLog)
-    gRtspLog = PR_NewLogModule("nsRtsp");
 }
 
 RtspControllerParent::~RtspControllerParent()
 {
 }
 
 void
 RtspControllerParent::ActorDestroy(ActorDestroyReason why)
--- a/netwerk/protocol/rtsp/rtsp/RTSPConnectionHandler.h
+++ b/netwerk/protocol/rtsp/rtsp/RTSPConnectionHandler.h
@@ -39,17 +39,21 @@
 #include <netdb.h>
 #include "nsPrintfCString.h"
 
 #include "mozilla/Logging.h"
 
 #include "prio.h"
 #include "prnetdb.h"
 
-extern PRLogModuleInfo* gRtspLog;
+namespace mozilla {
+namespace net {
+extern LazyLogModule gRtspLog;
+}
+}
 
 // If no access units are received within 10 secs, assume that the rtp
 // stream has ended and abort.
 static int64_t kAccessUnitTimeoutUs = 10000000ll;
 
 // The end-of-stream timer will be running in the last 2 seconds of duration.
 static int64_t kActivateEndOfStreamTimerUs = 2000000ll;
 
--- a/netwerk/protocol/rtsp/rtsp/RtspPrlog.h
+++ b/netwerk/protocol/rtsp/rtsp/RtspPrlog.h
@@ -3,17 +3,20 @@
 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef RTSPPRLOG_H
 #define RTSPPRLOG_H
 
 #include "mozilla/Logging.h"
-
-extern PRLogModuleInfo* gRtspLog;
+namespace mozilla {
+namespace net {
+extern LazyLogModule gRtspLog;
+}
+}
 
-#define LOGI(msg, ...) MOZ_LOG(gRtspLog, mozilla::LogLevel::Info, (msg, ##__VA_ARGS__))
-#define LOGV(msg, ...) MOZ_LOG(gRtspLog, mozilla::LogLevel::Debug, (msg, ##__VA_ARGS__))
-#define LOGE(msg, ...) MOZ_LOG(gRtspLog, mozilla::LogLevel::Error, (msg, ##__VA_ARGS__))
-#define LOGW(msg, ...) MOZ_LOG(gRtspLog, mozilla::LogLevel::Warning, (msg, ##__VA_ARGS__))
+#define LOGI(msg, ...) MOZ_LOG(mozilla::net::gRtspLog, mozilla::LogLevel::Info, (msg, ##__VA_ARGS__))
+#define LOGV(msg, ...) MOZ_LOG(mozilla::net::gRtspLog, mozilla::LogLevel::Debug, (msg, ##__VA_ARGS__))
+#define LOGE(msg, ...) MOZ_LOG(mozilla::net::gRtspLog, mozilla::LogLevel::Error, (msg, ##__VA_ARGS__))
+#define LOGW(msg, ...) MOZ_LOG(mozilla::net::gRtspLog, mozilla::LogLevel::Warning, (msg, ##__VA_ARGS__))
 
 #endif  // RTSPPRLOG_H
--- a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp
@@ -13,21 +13,20 @@
 #include "nsProxyRelease.h"
 #include "nsStandardURL.h"
 #include "LoadInfo.h"
 #include "nsIDOMNode.h"
 #include "mozilla/dom/ContentChild.h"
 
 using mozilla::dom::ContentChild;
 
-PRLogModuleInfo *webSocketLog = nullptr;
-
 namespace mozilla {
 namespace net {
 
+LazyLogModule webSocketLog("nsWebSocket");
 static uint64_t gNextWebSocketID = 0;
 
 // We use only 53 bits for the WebSocket serial ID so that it can be converted
 // to and from a JS value without loss of precision. The upper bits of the
 // WebSocket serial ID hold the process ID. The lower bits identify the
 // WebSocket.
 static const uint64_t kWebSocketIDTotalBits = 53;
 static const uint64_t kWebSocketIDProcessBits = 22;
@@ -37,19 +36,16 @@ BaseWebSocketChannel::BaseWebSocketChann
   : mWasOpened(0)
   , mClientSetPingInterval(0)
   , mClientSetPingTimeout(0)
   , mEncrypted(0)
   , mPingForced(0)
   , mPingInterval(0)
   , mPingResponseTimeout(10000)
 {
-  if (!webSocketLog)
-    webSocketLog = PR_NewLogModule("nsWebSocket");
-
   // Generation of a unique serial ID.
   uint64_t processID = 0;
   if (XRE_IsContentProcess()) {
     ContentChild* cc = ContentChild::GetSingleton();
     processID = cc->GetID();
   }
 
   uint64_t processBits = processID & ((uint64_t(1) << kWebSocketIDProcessBits) - 1);
--- a/netwerk/protocol/websocket/WebSocketChannelParent.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannelParent.cpp
@@ -30,18 +30,16 @@ WebSocketChannelParent::WebSocketChannel
                                                uint32_t aSerial)
   : mAuthProvider(aAuthProvider)
   , mLoadContext(aLoadContext)
   , mIPCOpen(true)
   , mSerial(aSerial)
 {
   // Websocket channels can't have a private browsing override
   MOZ_ASSERT_IF(!aLoadContext, aOverrideStatus == kPBOverride_Unset);
-  if (!webSocketLog)
-    webSocketLog = PR_NewLogModule("nsWebSocket");
   mObserver = new OfflineObserver(this);
 }
 
 WebSocketChannelParent::~WebSocketChannelParent()
 {
   if (mObserver) {
     mObserver->RemoveObserver();
   }
--- a/netwerk/protocol/websocket/WebSocketLog.h
+++ b/netwerk/protocol/websocket/WebSocketLog.h
@@ -6,14 +6,18 @@
 
 #ifndef WebSocketLog_h
 #define WebSocketLog_h
 
 #include "base/basictypes.h"
 #include "mozilla/Logging.h"
 #include "mozilla/net/NeckoChild.h"
 
-extern PRLogModuleInfo* webSocketLog;
+namespace mozilla {
+namespace net {
+extern LazyLogModule webSocketLog;
+}
+}
 
 #undef LOG
-#define LOG(args) MOZ_LOG(webSocketLog, mozilla::LogLevel::Debug, args)
+#define LOG(args) MOZ_LOG(mozilla::net::webSocketLog, mozilla::LogLevel::Debug, args)
 
 #endif
--- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
@@ -20,18 +20,16 @@ using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace net {
 
 WyciwygChannelParent::WyciwygChannelParent()
  : mIPCClosed(false)
  , mReceivedAppData(false)
 {
-  if (!gWyciwygLog)
-    gWyciwygLog = PR_NewLogModule("nsWyciwygChannel");
 }
 
 WyciwygChannelParent::~WyciwygChannelParent()
 {
 }
 
 void
 WyciwygChannelParent::ActorDestroy(ActorDestroyReason why)
--- a/netwerk/protocol/wyciwyg/nsWyciwyg.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwyg.cpp
@@ -1,9 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsWyciwyg.h"
 #include "nscore.h"
 
-PRLogModuleInfo *gWyciwygLog = nullptr;
+mozilla::LazyLogModule gWyciwygLog("nsWyciwygChannel");
 
+
--- a/netwerk/protocol/wyciwyg/nsWyciwyg.h
+++ b/netwerk/protocol/wyciwyg/nsWyciwyg.h
@@ -18,17 +18,17 @@
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsWyciwyg:5
 //    set NSPR_LOG_FILE=wyciwyg.log
 //
 // this enables LogLevel::Debug level information and places all output in
 // the file wyciwyg.log
 //
-extern PRLogModuleInfo *gWyciwygLog;
+extern mozilla::LazyLogModule gWyciwygLog;
 
 // http logging
 #define LOG1(args) MOZ_LOG(gWyciwygLog, mozilla::LogLevel::Error, args)
 #define LOG2(args) MOZ_LOG(gWyciwygLog, mozilla::LogLevel::Warning, args)
 #define LOG3(args) MOZ_LOG(gWyciwygLog, mozilla::LogLevel::Info, args)
 #define LOG4(args) MOZ_LOG(gWyciwygLog, mozilla::LogLevel::Debug, args)
 #define LOG(args) LOG4(args)
 
--- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.h
+++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.h
@@ -21,17 +21,17 @@ class nsICacheEntry;
 class nsIEventTarget;
 class nsIInputStream;
 class nsIInputStreamPump;
 class nsILoadGroup;
 class nsIOutputStream;
 class nsIProgressEventSink;
 class nsIURI;
 
-extern PRLogModuleInfo * gWyciwygLog;
+extern mozilla::LazyLogModule gWyciwygLog;
 
 //-----------------------------------------------------------------------------
 
 class nsWyciwygChannel final: public nsIWyciwygChannel,
                               public nsIStreamListener,
                               public nsICacheEntryOpenCallback,
                               public mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel>
 {
--- a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
@@ -17,19 +17,16 @@
 
 using namespace mozilla::net;
 #include "mozilla/net/WyciwygChannelChild.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 
 nsWyciwygProtocolHandler::nsWyciwygProtocolHandler() 
 {
-  if (!gWyciwygLog)
-    gWyciwygLog = PR_NewLogModule("nsWyciwygChannel");
-
   LOG(("Creating nsWyciwygProtocolHandler [this=%p].\n", this));
 }
 
 nsWyciwygProtocolHandler::~nsWyciwygProtocolHandler() 
 {
   LOG(("Deleting nsWyciwygProtocolHandler [this=%p]\n", this));
 }
 
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -46,45 +46,30 @@
 #ifdef MOZ_PEERCONNECTION
 #include "mtransport/runnable_utils.h"
 #endif
 
 #define DATACHANNEL_LOG(args) LOG(args)
 #include "DataChannel.h"
 #include "DataChannelProtocol.h"
 
-PRLogModuleInfo*
-GetDataChannelLog()
-{
-  static PRLogModuleInfo* sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("DataChannel");
-  return sLog;
-}
-
-PRLogModuleInfo*
-GetSCTPLog()
-{
-  static PRLogModuleInfo* sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("SCTP");
-  return sLog;
-}
-
 // Let us turn on and off important assertions in non-debug builds
 #ifdef DEBUG
 #define ASSERT_WEBRTC(x) MOZ_ASSERT((x))
 #elif defined(MOZ_WEBRTC_ASSERT_ALWAYS)
 #define ASSERT_WEBRTC(x) do { if (!(x)) { MOZ_CRASH(); } } while (0)
 #endif
 
 static bool sctp_initialized;
 
 namespace mozilla {
 
+LazyLogModule gDataChannelLog("DataChannel");
+static LazyLogModule gSCTPLog("SCTP");
+
 class DataChannelShutdown : public nsIObserver
 {
 public:
   // This needs to be tied to some form object that is guaranteed to be
   // around (singleton likely) unless we want to shutdown sctp whenever
   // we're not using it (and in which case we'd keep a refcnt'd object
   // ref'd by each DataChannelConnection to release the SCTP usrlib via
   // sctp_finish). Right now, the single instance of this class is
@@ -165,17 +150,17 @@ receive_cb(struct socket* sock, union sc
 }
 
 static void
 debug_printf(const char *format, ...)
 {
   va_list ap;
   char buffer[1024];
 
-  if (MOZ_LOG_TEST(GetSCTPLog(), LogLevel::Debug)) {
+  if (MOZ_LOG_TEST(gSCTPLog, LogLevel::Debug)) {
     va_start(ap, format);
 #ifdef _WIN32
     if (vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, format, ap) > 0) {
 #else
     if (vsnprintf(buffer, sizeof(buffer), format, ap) > 0) {
 #endif
       PR_LogPrint("%s", buffer);
     }
@@ -322,17 +307,17 @@ DataChannelConnection::Init(unsigned sho
         LOG(("sctp_init(%u)", aPort));
         usrsctp_init(aPort,
                      nullptr,
                      debug_printf
                     );
       }
 
       // Set logging to SCTP:LogLevel::Debug to get SCTP debugs
-      if (MOZ_LOG_TEST(GetSCTPLog(), LogLevel::Debug)) {
+      if (MOZ_LOG_TEST(gSCTPLog, LogLevel::Debug)) {
         usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
       }
 
       usrsctp_sysctl_set_sctp_blackhole(2);
       // ECN is currently not supported by the Firefox code
       usrsctp_sysctl_set_sctp_ecn_enable(0);
       sctp_initialized = true;
 
@@ -666,17 +651,17 @@ DataChannelConnection::ProcessQueuedOpen
     }
   }
 
 }
 void
 DataChannelConnection::SctpDtlsInput(TransportFlow *flow,
                                      const unsigned char *data, size_t len)
 {
-  if (MOZ_LOG_TEST(GetSCTPLog(), LogLevel::Debug)) {
+  if (MOZ_LOG_TEST(gSCTPLog, LogLevel::Debug)) {
     char *buf;
 
     if ((buf = usrsctp_dumppacket((void *)data, len, SCTP_DUMP_INBOUND)) != nullptr) {
       PR_LogPrint("%s", buf);
       usrsctp_freedumpbuffer(buf);
     }
   }
   // Pass the data to SCTP
@@ -696,17 +681,17 @@ DataChannelConnection::SendPacket(unsign
 /* static */
 int
 DataChannelConnection::SctpDtlsOutput(void *addr, void *buffer, size_t length,
                                       uint8_t tos, uint8_t set_df)
 {
   DataChannelConnection *peer = static_cast<DataChannelConnection *>(addr);
   int res;
 
-  if (MOZ_LOG_TEST(GetSCTPLog(), LogLevel::Debug)) {
+  if (MOZ_LOG_TEST(gSCTPLog, LogLevel::Debug)) {
     char *buf;
 
     if ((buf = usrsctp_dumppacket(buffer, length, SCTP_DUMP_OUTBOUND)) != nullptr) {
       PR_LogPrint("%s", buf);
       usrsctp_freedumpbuffer(buf);
     }
   }
   // We're async proxying even if on the STSThread because this is called
--- a/netwerk/sctp/datachannel/DataChannelLog.h
+++ b/netwerk/sctp/datachannel/DataChannelLog.h
@@ -5,15 +5,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DataChannelLog_h
 #define DataChannelLog_h
 
 #include "base/basictypes.h"
 #include "mozilla/Logging.h"
 
-extern PRLogModuleInfo* GetDataChannelLog();
-extern PRLogModuleInfo* GetSCTPLog();
+namespace mozilla {
+extern mozilla::LazyLogModule gDataChannelLog;
+}
 
 #undef LOG
-#define LOG(args) MOZ_LOG(GetDataChannelLog(), mozilla::LogLevel::Debug, args)
+#define LOG(args) MOZ_LOG(mozilla::gDataChannelLog, mozilla::LogLevel::Debug, args)
 
 #endif
--- a/netwerk/socket/nsSOCKSIOLayer.cpp
+++ b/netwerk/socket/nsSOCKSIOLayer.cpp
@@ -25,17 +25,18 @@
 using mozilla::LogLevel;
 using namespace mozilla::net;
 
 static PRDescIdentity nsSOCKSIOLayerIdentity;
 static PRIOMethods nsSOCKSIOLayerMethods;
 static bool firstTime = true;
 static bool ipv6Supported = true;
 
-static PRLogModuleInfo *gSOCKSLog;
+
+static mozilla::LazyLogModule gSOCKSLog("SOCKS");
 #define LOGDEBUG(args) MOZ_LOG(gSOCKSLog, mozilla::LogLevel::Debug, args)
 #define LOGERROR(args) MOZ_LOG(gSOCKSLog, mozilla::LogLevel::Error , args)
 
 class nsSOCKSSocketInfo : public nsISOCKSSocketInfo
                         , public nsIDNSListener
 {
     enum State {
         SOCKS_INITIAL,
@@ -1302,18 +1303,16 @@ nsSOCKSIOLayerAddToSocket(int32_t family
         nsSOCKSIOLayerMethods.acceptread = nsSOCKSIOLayerAcceptRead;
         nsSOCKSIOLayerMethods.getsockname = nsSOCKSIOLayerGetName;
         nsSOCKSIOLayerMethods.getpeername = nsSOCKSIOLayerGetPeerName;
         nsSOCKSIOLayerMethods.accept = nsSOCKSIOLayerAccept;
         nsSOCKSIOLayerMethods.listen = nsSOCKSIOLayerListen;
         nsSOCKSIOLayerMethods.close = nsSOCKSIOLayerClose;
 
         firstTime = false;
-
-        gSOCKSLog = PR_NewLogModule("SOCKS");
     }
 
     LOGDEBUG(("Entering nsSOCKSIOLayerAddToSocket()."));
 
     PRFileDesc *layer;
     PRStatus rv;
 
     layer = PR_CreateIOLayerStub(nsSOCKSIOLayerIdentity, &nsSOCKSIOLayerMethods);
--- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
+++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
@@ -25,18 +25,17 @@
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsFTPDirListConv:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables LogLevel::Debug level information and places all output in
 // the file nspr.log
 //
-PRLogModuleInfo* gFTPDirListConvLog = nullptr;
-
+static mozilla::LazyLogModule gFTPDirListConvLog("nsFTPDirListingConv");
 
 // nsISupports implementation
 NS_IMPL_ISUPPORTS(nsFTPDirListingConv,
                   nsIStreamConverter,
                   nsIStreamListener, 
                   nsIRequestObserver)
 
 
@@ -185,29 +184,16 @@ nsFTPDirListingConv::nsFTPDirListingConv
     mSentHeading        = false;
 }
 
 nsFTPDirListingConv::~nsFTPDirListingConv() {
     NS_IF_RELEASE(mFinalListener);
 }
 
 nsresult
-nsFTPDirListingConv::Init() {
-    //
-    // Initialize the global PRLogModule for FTP Protocol logging 
-    // if necessary...
-    //
-    if (nullptr == gFTPDirListConvLog) {
-        gFTPDirListConvLog = PR_NewLogModule("nsFTPDirListingConv");
-    }
-
-    return NS_OK;
-}
-
-nsresult
 nsFTPDirListingConv::GetHeaders(nsACString& headers,
                                 nsIURI* uri)
 {
     nsresult rv = NS_OK;
     // build up 300 line
     headers.AppendLiteral("300: ");
 
     // Bug 111117 - don't print the password
@@ -353,10 +339,10 @@ NS_NewFTPDirListingConv(nsFTPDirListingC
     if (! aFTPDirListingConv)
         return NS_ERROR_NULL_POINTER;
 
     *aFTPDirListingConv = new nsFTPDirListingConv();
     if (! *aFTPDirListingConv)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(*aFTPDirListingConv);
-    return (*aFTPDirListingConv)->Init();
+    return NS_OK;
 }
--- a/netwerk/streamconv/converters/nsFTPDirListingConv.h
+++ b/netwerk/streamconv/converters/nsFTPDirListingConv.h
@@ -29,17 +29,16 @@ public:
     // nsIStreamListener methods
     NS_DECL_NSISTREAMLISTENER
 
     // nsIRequestObserver methods
     NS_DECL_NSIREQUESTOBSERVER
 
     // nsFTPDirListingConv methods
     nsFTPDirListingConv();
-    nsresult Init();
 
 private:
     virtual ~nsFTPDirListingConv();
 
     // Get the application/http-index-format headers
     nsresult GetHeaders(nsACString& str, nsIURI* uri);
     char*    DigestBufferLines(char *aBuffer, nsCString &aString);
 
--- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
+++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
@@ -15,22 +15,22 @@
 #include "nsThreadUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsIForcePendingChannel.h"
 
 // brotli headers
 #include "state.h"
 #include "decode.h"
 
-extern PRLogModuleInfo *gHttpLog;
-#define LOG(args) MOZ_LOG(gHttpLog, mozilla::LogLevel::Debug, args)
-
 namespace mozilla {
 namespace net {
 
+extern LazyLogModule gHttpLog;
+#define LOG(args) MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Debug, args)
+
 // nsISupports implementation
 NS_IMPL_ISUPPORTS(nsHTTPCompressConv,
                   nsIStreamConverter,
                   nsIStreamListener,
                   nsIRequestObserver,
                   nsICompressConvStats)
 
 // nsFTPDirListingConv methods
--- a/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
+++ b/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
@@ -37,17 +37,17 @@
 #define EINTR_RETRY(x) MOZ_TEMP_FAILURE_RETRY(x)
 
 // period during which to absorb subsequent network change events, in
 // milliseconds
 static const unsigned int kNetworkChangeCoalescingPeriod  = 1000;
 
 using namespace mozilla;
 
-static PRLogModuleInfo *gNotifyAddrLog = nullptr;
+static LazyLogModule gNotifyAddrLog("nsNotifyAddr");
 #define LOG(args) MOZ_LOG(gNotifyAddrLog, mozilla::LogLevel::Debug, args)
 
 #define NETWORK_NOTIFY_CHANGED_PREF "network.notify.changed"
 
 NS_IMPL_ISUPPORTS(nsNotifyAddrListener,
                   nsINetworkLinkService,
                   nsIRunnable,
                   nsIObserver)
@@ -344,19 +344,16 @@ class NuwaMarkLinkMonitorThreadRunner : 
         return NS_OK;
     }
 };
 #endif
 
 nsresult
 nsNotifyAddrListener::Init(void)
 {
-    if (!gNotifyAddrLog)
-        gNotifyAddrLog = PR_NewLogModule("nsNotifyAddr");
-
     nsCOMPtr<nsIObserverService> observerService =
         mozilla::services::GetObserverService();
     if (!observerService)
         return NS_ERROR_FAILURE;
 
     nsresult rv = observerService->AddObserver(this, "xpcom-shutdown-threads",
                                                false);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/netwerk/system/mac/nsNetworkLinkService.mm
+++ b/netwerk/system/mac/nsNetworkLinkService.mm
@@ -14,17 +14,17 @@
 
 #import <Cocoa/Cocoa.h>
 #import <netinet/in.h>
 
 #define NETWORK_NOTIFY_CHANGED_PREF "network.notify.changed"
 
 using namespace mozilla;
 
-static PRLogModuleInfo *gNotifyAddrLog = nullptr;
+static LazyLogModule gNotifyAddrLog("nsNotifyAddr");
 #define LOG(args) MOZ_LOG(gNotifyAddrLog, mozilla::LogLevel::Debug, args)
 
 // If non-successful, extract the error code and return it.  This
 // error code dance is inspired by
 // http://developer.apple.com/technotes/tn/tn1145.html
 static OSStatus getErrorCodeBool(Boolean success)
 {
     OSStatus err = noErr;
@@ -120,19 +120,16 @@ nsNetworkLinkService::IPConfigChanged(SC
     service->SendEvent(true);
 }
 
 nsresult
 nsNetworkLinkService::Init(void)
 {
     nsresult rv;
 
-    if (!gNotifyAddrLog)
-        gNotifyAddrLog = PR_NewLogModule("nsNotifyAddr");
-
     nsCOMPtr<nsIObserverService> observerService =
         do_GetService("@mozilla.org/observer-service;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = observerService->AddObserver(this, "xpcom-shutdown", false);
     NS_ENSURE_SUCCESS(rv, rv);
 
     Preferences::AddBoolVarCache(&mAllowChangedEvent,
--- a/netwerk/system/win32/nsNotifyAddrListener.cpp
+++ b/netwerk/system/win32/nsNotifyAddrListener.cpp
@@ -30,17 +30,17 @@
 #include "nsCRT.h"
 #include "mozilla/Preferences.h"
 
 #include <iptypes.h>
 #include <iphlpapi.h>
 
 using namespace mozilla;
 
-static PRLogModuleInfo *gNotifyAddrLog = nullptr;
+static LazyLogModule gNotifyAddrLog("nsNotifyAddr");
 #define LOG(args) MOZ_LOG(gNotifyAddrLog, mozilla::LogLevel::Debug, args)
 
 static HMODULE sNetshell;
 static decltype(NcFreeNetconProperties)* sNcFreeNetconProperties;
 
 static HMODULE sIphlpapi;
 static decltype(NotifyIpInterfaceChange)* sNotifyIpInterfaceChange;
 static decltype(CancelMibChangeNotify2)* sCancelMibChangeNotify2;
@@ -243,19 +243,16 @@ nsNotifyAddrListener::Observe(nsISupport
         Shutdown();
 
     return NS_OK;
 }
 
 nsresult
 nsNotifyAddrListener::Init(void)
 {
-    if (!gNotifyAddrLog)
-        gNotifyAddrLog = PR_NewLogModule("nsNotifyAddr");
-
     nsCOMPtr<nsIObserverService> observerService =
         mozilla::services::GetObserverService();
     if (!observerService)
         return NS_ERROR_FAILURE;
 
     nsresult rv = observerService->AddObserver(this, "xpcom-shutdown-threads",
                                                false);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/netwerk/wifi/nsWifiAccessPoint.cpp
+++ b/netwerk/wifi/nsWifiAccessPoint.cpp
@@ -2,20 +2,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsWifiAccessPoint.h"
 #include "nsString.h"
 #include "nsMemory.h"
 #include "mozilla/Logging.h"
 
-extern PRLogModuleInfo *gWifiMonitorLog;
+extern mozilla::LazyLogModule gWifiMonitorLog;
 #define LOG(args)     MOZ_LOG(gWifiMonitorLog, mozilla::LogLevel::Debug, args)
 
-
 NS_IMPL_ISUPPORTS(nsWifiAccessPoint, nsIWifiAccessPoint)
 
 nsWifiAccessPoint::nsWifiAccessPoint()
 {
   // make sure these are null terminated (because we are paranoid)
   mMac[0] = '\0';
   mSsid[0] = '\0';
   mSsidLen = 0;
--- a/netwerk/wifi/nsWifiMonitor.cpp
+++ b/netwerk/wifi/nsWifiMonitor.cpp
@@ -15,30 +15,28 @@
 #include "nsWifiAccessPoint.h"
 
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/Services.h"
 
 using namespace mozilla;
 
-PRLogModuleInfo *gWifiMonitorLog;
+LazyLogModule gWifiMonitorLog("WifiMonitor");
 
 NS_IMPL_ISUPPORTS(nsWifiMonitor,
                   nsIRunnable,
                   nsIObserver,
                   nsIWifiMonitor)
 
 nsWifiMonitor::nsWifiMonitor()
 : mKeepGoing(true)
 , mThreadComplete(false)
 , mReentrantMonitor("nsWifiMonitor.mReentrantMonitor")
 {
-  gWifiMonitorLog = PR_NewLogModule("WifiMonitor");
-
   nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
   if (obsSvc)
     obsSvc->AddObserver(this, "xpcom-shutdown", false);
 
   LOG(("@@@@@ wifimonitor created\n"));
 }
 
 nsWifiMonitor::~nsWifiMonitor()
--- a/netwerk/wifi/nsWifiMonitor.h
+++ b/netwerk/wifi/nsWifiMonitor.h
@@ -21,17 +21,17 @@
 #include "nsITimer.h"
 #include "mozilla/Attributes.h"
 #include "nsIInterfaceRequestor.h"
 
 #ifdef XP_WIN
 #include "win_wifiScanner.h"
 #endif
 
-extern PRLogModuleInfo *gWifiMonitorLog;
+extern mozilla::LazyLogModule gWifiMonitorLog;
 #define LOG(args)     MOZ_LOG(gWifiMonitorLog, mozilla::LogLevel::Debug, args)
 
 class nsWifiAccessPoint;
 
 #define kDefaultWifiScanInterval 5 /* seconds */
 
 class nsWifiListener
 {
--- a/netwerk/wifi/nsWifiMonitorGonk.cpp
+++ b/netwerk/wifi/nsWifiMonitorGonk.cpp
@@ -17,27 +17,25 @@
 #include "nsComponentManagerUtils.h"
 #include "mozilla/Services.h"
 
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 
 using namespace mozilla;
 
-PRLogModuleInfo *gWifiMonitorLog;
+LazyLogModule gWifiMonitorLog("WifiMonitor");
 
 NS_IMPL_ISUPPORTS(nsWifiMonitor,
                   nsIWifiMonitor,
                   nsIObserver,
                   nsIWifiScanResultsReady)
 
 nsWifiMonitor::nsWifiMonitor()
 {
-  gWifiMonitorLog = PR_NewLogModule("WifiMonitor");
-
   nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
   if (obsSvc) {
     obsSvc->AddObserver(this, "xpcom-shutdown", false);
   }
   LOG(("@@@@@ wifimonitor created\n"));
 }
 
 nsWifiMonitor::~nsWifiMonitor()