fiware-cygnus icon indicating copy to clipboard operation
fiware-cygnus copied to clipboard

Provide one log file for each sink

Open AlvaroVega opened this issue 3 years ago • 3 comments

This will implies a design session

AlvaroVega avatar Jul 09 '21 09:07 AlvaroVega

@AlvaroVega, I have updated configurations in log4j.propertise file to provide one log file for each sink but it is not working.

From below configuratios, I want to display only com.iot.telefonica.cygnus.sinks logs in ${flume.log.dir}/mongoSink_logfile.log file.

APPENDRES FOR MONGO-SINK
log4j.appender.MONGO-SINK_LOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.MONGO-SINK_LOGFILE.MaxFileSize=100MB
log4j.appender.MONGO-SINK_LOGFILE.MaxBackupIndex=10
log4j.appender.MONGO-SINK_LOGFILE.File=${flume.log.dir}/mongoSink_logfile.log
log4j.appender.MONGO-SINK_LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.MONGO-SINK_LOGFILE.layout.ConversionPattern=time=%d{yyyy-MM-dd}T%d{HH:mm:ss.SSS}Z | lvl=%p | corr=%X{correlatorId} | trans=%X{transactionId} | srv=%X{service} | subsrv=%X{subservice} | comp=%X{agent} | op=%M | msg=%C[%L] : %m%n

#LOGGER FOR MONGO-SINK
log4j.logger.com.iot.telefonica.cygnus.sinks=DEBUG,MONGO-SINK_LOGFILE

Current behavior: If I don't specify appender name for log4j.rootLogger then in ${flume.log.dir}/mongoSink_logfile.log file logs will not print. If I specify appender name for log4j.rootLogger then in ${flume.log.dir}/mongoSink_logfile.log file, logs of all the loggers will print.

I have verified behavior with sample code and Expected behavior is: If I don't specify appender name for log4j.rootLogger then in ${flume.log.dir}/mongoSink_logfile.log file logs of com.iot.telefonica.cygnus.sinks will print. If I specify appender name for log4j.rootLogger then only in ${flume.log.dir}/mongoSink_logfile.log file, logs of all the loggers will print.

Query: Is there any configuration or code changes required?

kajal583 avatar Jan 31 '23 07:01 kajal583

This is a gentle reminder!! Please provide your opinion on this query.

kajal583 avatar Feb 23 '23 03:02 kajal583

Regarding the general log4j config file, you can find it here: https://github.com/telefonicaid/fiware-cygnus/blob/bc4daaa78bc303f8283196ebabad3f12b5a63a74/cygnus-common/conf/log4j2.properties.template

Could you provide more information about the files you are editing?

mapedraza avatar Feb 23 '23 09:02 mapedraza