From 6dee9f7b0c10ef1e48abe5751091479f2018ddf3 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Wed, 30 May 2012 15:37:53 -0700 Subject: [PATCH] Use a logger in SocketAddresses - Contributed by @CruzBishop --- common/src/main/java/io/netty/util/SocketAddresses.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/io/netty/util/SocketAddresses.java b/common/src/main/java/io/netty/util/SocketAddresses.java index edc0ef6220..93009adb74 100644 --- a/common/src/main/java/io/netty/util/SocketAddresses.java +++ b/common/src/main/java/io/netty/util/SocketAddresses.java @@ -15,6 +15,9 @@ */ package io.netty.util; +import io.netty.logging.InternalLogger; +import io.netty.logging.InternalLoggerFactory; + import java.net.InetAddress; import java.net.UnknownHostException; @@ -22,6 +25,9 @@ public final class SocketAddresses { public static final InetAddress LOCALHOST; + private static final InternalLogger logger = + InternalLoggerFactory.getInstance(SocketAddresses.class); + static { // We cache this because some machine takes almost forever to return // from InetAddress.getLocalHost(). I think it's due to the incorrect @@ -36,8 +42,7 @@ public final class SocketAddresses { try { localhost = InetAddress.getByAddress(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }); } catch (UnknownHostException e2) { - System.err.println("Failed to get the localhost."); - e2.printStackTrace(); + logger.error("Failed to resolve localhost", e2); } } }