The printed journal where to go?

1.1 two projects:

umf-pay-sdk

|---umf-pay-sdk-core

|--umf-pay-demo

Among them, the project's payment interface for docking interaction, dependent on log4j to print the log. umf-pay-sdk-core is a module, the compiler will be labeled jar. umf-pay-demo main test is used to test api ymf-pay-sdk-core of.

draft_server

Is an application, log frame using log4j2. It depends on many jar, including the umf-pay-sdk-core.

 

1.2 umf-pay-sdk-core diary way is to use log4j. And defines log4j.properties.

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
private static final Logger log = LogManager.getLogger("UMF");
########################################################
# For LOG4J / Logger4
########################################################
log4j.rootCategory=INFO, stdout,UMF
log4j.category.com.umpay.sign = INFO, UMF
log4j.additivity.com.umpay.sign=true


log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[UMF]%d{yyyyMMdd.HHmmss.SSS} %p [%t] %c{1}.%M(%L) | %m%n

########################
# Daily Rolling File Appender
#######################
log4j.appender.UMF = org.apache.log4j.DailyRollingFileAppender
log4j.appender.UMF.File = UMF.log
log4j.appender.UMF.DatePattern	='.'yyyyMMdd
log4j.appender.UMF.layout	=org.apache.log4j.PatternLayout
log4j.appender.UMF.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss.SSS}],%m%n
View Code

 

 

Test environment running draft_server, occurs when testing linked the payment bug, had to come through the interrogation log, but can not find UMF.log file in the test environment.

 

Later, when the local investigation found that the diary is not without, but, logging in a file called jeewxApi.log of it. why?

The original, Ctrl + Shift + N to find when log4j.properties file, found found two: one in the jeewx-api.jar where one umf-pay-sdk-core.jar years.

It seems, log4j scans to log4j.properties under jeewx-api, it reads the configuration file to the diary. To confirm, delete log4j.properties file under jeewx-api, sure enough, UMF.log appeared.

 

If the two jar in the log4j.properties have deleted it?

At this time, there will be the following alarm log, meaning: can not find the appropriate appender, then, people will remember the log.

log4j:WARN No appenders could be found for logger (UMF).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

 

Technology with a keen sense of smell after 90 colleagues communication that umf-pay-sdk-core in the logs with log4j actually wrong. The best use slf4j. In this case, it will find the main program dependent on logging framework. That unity will be recorded in the log configured draft_server program log4j2 log file. Unified log records, which will help us to troubleshoot the problem.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger log =  LoggerFactory.getLogger("UMF");

 

Guess you like

Origin www.cnblogs.com/buguge/p/12125682.html