Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Feature]: API Logging Improvements: per capp logging #3429

Open
chanikag opened this issue Jul 17, 2024 · 1 comment
Open

[New Feature]: API Logging Improvements: per capp logging #3429

chanikag opened this issue Jul 17, 2024 · 1 comment
Assignees

Comments

@chanikag
Copy link
Contributor

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

@chanikag chanikag self-assigned this Jul 17, 2024
@chanikag
Copy link
Contributor Author

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] wso2/wso2-synapse#286
[2] wso2/wso2-synapse#2198
[3] wso2/wso2-synapse#2203

Thanks

chanikag added a commit to chanikag/docs-mi that referenced this issue Jul 18, 2024
chanikag added a commit to chanikag/micro-integrator that referenced this issue Sep 2, 2024
This PR contains integration tests for [1]

[1] wso2#3429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants