Open chanikag opened 1 month ago
Per capp logging support was introduced earlier by [1]. But later it was removed when moving to log4j2. Now, the fix is added with PR [2] [3] to bring it back with log4j2 support.
You can add %X{Artifact-Container} in the log pattern in log4j.properties file.
For example:
# CARBON_LOGFILE is set to be a DailyRollingFileAppender using a PatternLayout.
appender.CARBON_LOGFILE.type = RollingFile
appender.CARBON_LOGFILE.name = CARBON_LOGFILE
appender.CARBON_LOGFILE.fileName = ${sys:logfiles.home}/wso2carbon.log
appender.CARBON_LOGFILE.filePattern = ${sys:logfiles.home}/wso2carbon-%d{MM-dd-yyyy}.log
appender.CARBON_LOGFILE.layout.type = PatternLayout
appender.CARBON_LOGFILE.layout.pattern = [%d] %5p {%c} |%X{Artifact-Container}| - %m%ex%n
appender.CARBON_LOGFILE.policies.type = Policies
appender.CARBON_LOGFILE.policies.time.type = TimeBasedTriggeringPolicy
appender.CARBON_LOGFILE.policies.time.interval = 1
appender.CARBON_LOGFILE.policies.time.modulate = true
appender.CARBON_LOGFILE.policies.size.type = SizeBasedTriggeringPolicy
appender.CARBON_LOGFILE.policies.size.size=10MB
appender.CARBON_LOGFILE.strategy.type = DefaultRolloverStrategy
appender.CARBON_LOGFILE.strategy.max = 20
appender.CARBON_LOGFILE.filter.threshold.type = ThresholdFilter
appender.CARBON_LOGFILE.filter.threshold.level = DEBUG
Then it will append a content with capp name in the logs: For example:
[2024-07-11 08:34:36,970] INFO {org.apache.synapse.mediators.builtin.LogMediator} |[ Deployed From Artifact Container: abcProjectCompositeExporter ] | - {api:testAPI} BEGIN = true
[2024-07-11 08:34:46,110] INFO {org.apache.synapse.core.axis2.TimeoutHandler} |[ Deployed From Artifact Container: abcProjectCompositeExporter ] | - This engine will expire all callbacks after GLOBAL_TIMEOUT: 120 seconds, irrespective of the timeout action, after the specified or optional timeout
[1] https://github.com/wso2/wso2-synapse/pull/286 [2] https://github.com/wso2/wso2-synapse/pull/2198 [3] https://github.com/wso2/wso2-synapse/pull/2203
Thanks
Description
Even though we have per-API-based logging, it does not cater to the complete requirement of having a single log file for an integration. The requirement is to introduce per capp logging
Describe your problem(s)
No response
Describe your solution(s)
No response
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response