切换日志组件

This commit is contained in:
egzosn
2021-05-30 20:51:16 +08:00
parent 0fb2b8dba9
commit d40efb21c5
17 changed files with 73 additions and 70 deletions

View File

@@ -28,8 +28,9 @@
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<!-- / log4j -->

View File

@@ -11,8 +11,9 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.egzosn.pay.common.bean.MethodType;
@@ -38,7 +39,7 @@ import com.egzosn.pay.common.util.str.StringUtils;
* </pre>
*/
public abstract class BasePayService<PC extends PayConfigStorage> implements PayService<PC> {
protected final Log LOG = LogFactory.getLog(getClass());
protected final Logger LOG = LoggerFactory.getLogger(getClass());
protected PC payConfigStorage;
protected HttpRequestTemplate requestTemplate;
@@ -112,7 +113,7 @@ public abstract class BasePayService<PC extends PayConfigStorage> implements Pay
base64ClientID = com.egzosn.pay.common.util.sign.encrypt.Base64.encode(String.format("%s:%s", user, password).getBytes("UTF-8"));
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
LOG.error("", e);
}
return base64ClientID;
@@ -202,7 +203,7 @@ public abstract class BasePayService<PC extends PayConfigStorage> implements Pay
}
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
LOG.error("", e);
}
}
params.put(name, valueStr);

View File

@@ -1,13 +1,14 @@
package com.egzosn.pay.common.api;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.egzosn.pay.common.bean.PayMessage;
import com.egzosn.pay.common.bean.PayOutMessage;
import com.egzosn.pay.common.exception.PayErrorException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Map;
/**
* 默认处理支付回调消息的处理器接口
@@ -21,7 +22,7 @@ import java.util.Map;
*/
public class DefaultPayMessageHandler implements PayMessageHandler<PayMessage, PayService> {
protected final Log LOG = LogFactory.getLog(DefaultPayMessageHandler.class);
protected final Logger LOG = LoggerFactory.getLogger(DefaultPayMessageHandler.class);
/**
* @param payMessage 支付消息
* @param context 上下文如果handler或interceptor之间有信息要传递可以用这个

View File

@@ -8,8 +8,8 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.egzosn.pay.common.bean.PayMessage;
import com.egzosn.pay.common.bean.PayOutMessage;
@@ -44,8 +44,8 @@ import com.egzosn.pay.common.util.LogExceptionHandler;
* @author egan
*/
public class PayMessageRouter {
protected final Logger LOG = LoggerFactory.getLogger(PayMessageRouter.class);
protected final Log LOG = LogFactory.getLog(PayMessageRouter.class);
/**
* 异步线程大小
*/

View File

@@ -9,8 +9,8 @@ import java.net.URI;
import java.nio.charset.Charset;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
@@ -46,7 +46,7 @@ import com.egzosn.pay.common.util.str.StringUtils;
* </pre>
*/
public class ClientHttpRequest<T> extends HttpEntityEnclosingRequestBase implements org.apache.http.client.ResponseHandler<T> {
protected static final Log LOG = LogFactory.getLog(ClientHttpRequest.class);
protected static final Logger LOG = LoggerFactory.getLogger(ClientHttpRequest.class);
public static final ContentType APPLICATION_FORM_URLENCODED_UTF_8 = ContentType.create("application/x-www-form-urlencoded", Consts.UTF_8);
public static final ContentType APPLICATION_XML_UTF_8 = ContentType.create("application/xml", Consts.UTF_8);

View File

@@ -4,8 +4,8 @@ import com.egzosn.pay.common.bean.MethodType;
import com.egzosn.pay.common.bean.result.PayException;
import com.egzosn.pay.common.exception.PayErrorException;
import com.egzosn.pay.common.util.str.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -44,7 +44,7 @@ import java.util.Map;
*/
public class HttpRequestTemplate {
protected static final Log LOG = LogFactory.getLog(HttpRequestTemplate.class);
protected static final Logger LOG = LoggerFactory.getLogger(HttpRequestTemplate.class);
protected CloseableHttpClient httpClient;
@@ -123,7 +123,7 @@ public class HttpRequestTemplate {
try {
return sslsf = new SSLConnectionSocketFactory(SSLContext.getDefault());
} catch (NoSuchAlgorithmException e) {
LOG.error(e);
LOG.error("", e);
}
}
@@ -149,9 +149,9 @@ public class HttpRequestTemplate {
return sslsf;
} catch (IOException e) {
LOG.error(e);
LOG.error("", e);
} catch (GeneralSecurityException e) {
LOG.error(e);
LOG.error("", e);
}
return null;

View File

@@ -5,8 +5,8 @@ import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.egzosn.pay.common.bean.result.PayException;
@@ -22,7 +22,7 @@ import com.egzosn.pay.common.exception.PayErrorException;
* </pre>
*/
public final class UriVariables {
private static final Log LOG = LogFactory.getLog(UriVariables.class);
private static final Logger LOG = LoggerFactory.getLogger(UriVariables.class);
private UriVariables() {
}
@@ -213,7 +213,7 @@ public final class UriVariables {
return URLEncoder.encode(str, enc);
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
LOG.error("", e);
}
return str;
}

View File

@@ -8,8 +8,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.http.util.Args;
/**
@@ -22,7 +22,7 @@ import org.apache.http.util.Args;
* </pre>
*/
public final class DateUtils {
private static final Log LOG = LogFactory.getLog(DateUtils.class);
private static final Logger LOG = LoggerFactory.getLogger(DateUtils.class);
private DateUtils() {
}
@@ -81,7 +81,7 @@ public final class DateUtils {
return formatFor.parse(date);
}
catch (ParseException e) {
LOG.error(e);
LOG.error("", e);
}
return null;
}

View File

@@ -2,8 +2,8 @@ package com.egzosn.pay.common.util;
import com.egzosn.pay.common.api.PayErrorExceptionHandler;
import com.egzosn.pay.common.exception.PayErrorException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,12 +20,12 @@ import org.apache.commons.logging.LogFactory;
*/
public class LogExceptionHandler implements PayErrorExceptionHandler {
protected final Log log = LogFactory.getLog(PayErrorExceptionHandler.class);
protected final Logger LOGGER = LoggerFactory.getLogger(PayErrorExceptionHandler.class);
@Override
public void handle(PayErrorException e) {
log.error("Error happens", e);
LOGGER.error("Error happens", e);
}

View File

@@ -15,8 +15,8 @@
package com.egzosn.pay.common.util.sign;
import com.egzosn.pay.common.util.str.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -35,7 +35,7 @@ import java.util.Enumeration;
* 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
*/
public class CertDescriptor {
protected static final Log LOG = LogFactory.getLog(CertDescriptor.class);
protected static final Logger LOG = LoggerFactory.getLogger(CertDescriptor.class);
/**
* 证书容器,存储对商户请求报文签名私钥证书.
*/

View File

@@ -6,8 +6,8 @@ import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.Signature;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.egzosn.pay.common.bean.result.PayException;
import com.egzosn.pay.common.exception.PayErrorException;
@@ -15,7 +15,7 @@ import com.egzosn.pay.common.util.sign.encrypt.sm3.SM3Digest;
public class SecureUtil {
private static final Log LOG = LogFactory.getLog(SecureUtil.class);
private static final Logger LOG = LoggerFactory.getLogger(SecureUtil.class);
/**
* 算法常量: SHA1
*/
@@ -49,7 +49,7 @@ public class SecureUtil {
return md.digest();
}
catch (NoSuchAlgorithmException e) {
LOG.error(e);
LOG.error("", e);
return null;
}
}
@@ -77,7 +77,7 @@ public class SecureUtil {
return sha1StrBuff.toString().getBytes(encoding);
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
LOG.error("", e);
return null;
}
}
@@ -139,7 +139,7 @@ public class SecureUtil {
bytes = SecureUtil.sm3(data.getBytes(encoding));
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
LOG.error("", e);
}
StringBuilder sm3StrBuff = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {

View File

@@ -17,8 +17,8 @@ import java.util.UUID;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.http.message.BasicNameValuePair;
import com.egzosn.pay.common.bean.SignType;
@@ -93,13 +93,13 @@ public enum SignUtils implements SignType {
return sb.toString().toUpperCase();
}
catch (NoSuchAlgorithmException e) {
LOG.error(e);
LOG.error("", e);
}
catch (InvalidKeyException e) {
LOG.error(e);
LOG.error("", e);
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
LOG.error("", e);
}
throw new PayErrorException(new PayException("fail", "HMACSHA256 签名异常"));
@@ -177,7 +177,7 @@ public enum SignUtils implements SignType {
return com.egzosn.pay.common.util.sign.encrypt.RSA2.verify(text, sign, publicKey, characterEncoding);
}
};
private static final Log LOG = LogFactory.getLog(SignUtils.class);
private static final Logger LOG = LoggerFactory.getLogger(SignUtils.class);
/**
* 把数组所有元素排序,并按照“参数=参数值”的模式用“@param separator”字符拼接成字符串

View File

@@ -17,8 +17,8 @@ import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* RSA
@@ -29,7 +29,7 @@ import org.apache.commons.logging.LogFactory;
* </pre>
*/
public class RSA {
private static final Log LOG = LogFactory.getLog(RSA.class);
private static final Logger LOG = LoggerFactory.getLogger(RSA.class);
private static final String ALGORITHM = "RSA";
@@ -61,10 +61,10 @@ public class RSA {
return Base64.encode(signed);
}
catch (GeneralSecurityException e) {
LOG.error(e);
LOG.error("", e);
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
LOG.error("", e);
}
return null;
@@ -89,10 +89,10 @@ public class RSA {
return Base64.encode(signed);
}
catch (GeneralSecurityException e) {
LOG.error(e);
LOG.error("", e);
}
catch (UnsupportedEncodingException e) {
LOG.error(e);
LOG.error("", e);
}
return null;
@@ -142,10 +142,10 @@ public class RSA {
return signature.verify(Base64.decode(sign));
}
catch (GeneralSecurityException e) {
LOG.error(e);
LOG.error("", e);
}
catch (IOException e) {
LOG.error(e);
LOG.error("", e);
}
return false;
}
@@ -168,10 +168,10 @@ public class RSA {
return signature.verify(Base64.decode(sign));
}
catch (GeneralSecurityException e) {
LOG.error(e);
LOG.error("", e);
}
catch (IOException e) {
LOG.error(e);
LOG.error("", e);
}
return false;
}