telefonicaid / fiware-cygnus

A connector in charge of persisting context data sources into other third-party databases and storage systems, creating a historical view of the context
https://fiware-cygnus.rtfd.io/
GNU Affero General Public License v3.0
65 stars 104 forks source link

Provide one log file for each sink #2065

Open AlvaroVega opened 3 years ago

AlvaroVega commented 3 years ago

This will implies a design session

kajal583 commented 1 year ago

@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.logfile.

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 commented 1 year ago

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

mapedraza commented 1 year ago

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?