public abstract class LoggerHelper extends Object
| Constructor and Description |
|---|
LoggerHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
activePrudent(Logger logger,
boolean prudent)
When prudent is set to true, file appenders from multiple JVMs can safely write to the same file.
|
static String |
getErrorCodeStr(String errorCode)
Deprecated.
|
static String |
getErrorCodeStr(String productName,
String errorCode,
String errorType,
String message)
根据productName获取统一格式的ErrorCode输出
|
static String |
getLogFile(String productName,
String fileName)
获取中间件产品日志路径
优先使用-DJM.LOG.PATH参数,且必须是绝对路径
其次是{user.home}/logs/
比如hsf调用:LoggerHelper.getLogFile("hsf", "hsf.log"),则返回{user.home}/logs/hsf/hsf.log
|
static String |
getLogFileP(String productName,
String fileName) |
static String |
getLogpath()
获取中间件日志根目录,以File.separator结尾
|
static String |
getPattern()
获取中间件日志特定格式
|
static String |
getPattern(String productName)
获取中间件日志格式,优先使用用户产品自定义的格式,logback/log4j通用
|
static String |
getResourceBundleString(String productName,
String code)
获取国际化的message,如果找不到,则返回原始的code
|
static void |
setPattern(String productName,
String pattern)
设置特定中间件产品的日志格式,注意,这里的格式需要自己保证在 log4j/logback 下都兼容,框架不做校验,同时控制台输出仍会采用中间件的特定格式
|
static void |
setResourceBundle(String productName,
String bundleName)
设置产品的日志国际化properties文件
|
public static String getLogpath()
public static String getLogFile(String productName, String fileName)
获取中间件产品日志路径
优先使用-DJM.LOG.PATH参数,且必须是绝对路径
其次是{user.home}/logs/
比如hsf调用:LoggerHelper.getLogFile("hsf", "hsf.log"),则返回{user.home}/logs/hsf/hsf.log
productName - 中间件产品名,如hsf, tddlfileName - 日志文件名,如hsf.log,如需要二级子目录,可以传 subDir + File.separator + *.logpublic static String getPattern(String productName)
public static String getPattern()
public static void setPattern(String productName, String pattern)
productName - 中间件产品名,如hsf, tddlpattern - 日志格式public static void setResourceBundle(String productName, String bundleName)
productName - 中间件产品名,如hsf, tddlbundleName - bundleNamepublic static String getResourceBundleString(String productName, String code)
productName - 中间件产品名,如hsf, tddlcode - code@Deprecated public static String getErrorCodeStr(String errorCode)
errorCode - public static String getErrorCodeStr(String productName, String errorCode, String errorType, String message)
productName - 如 HSF,会根据 HSF.ErrorCodeMoreUrl 从 System属性中获取 more url 前缀,如http://console.taobao.net/jm/errorCode - 错误码,如HSF-001errorType - 错误类型message - 出错异常信息public static void activePrudent(Logger logger, boolean prudent)
Only support by logback
prudent - Copyright © 2018 Alibaba Group. All rights reserved.