Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/server/appsmith-interfaces/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/net.logstash.logback/logstash-logback-encoder -->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>8.0</version>
</dependency>

<dependency>
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ spring.codec.max-in-memory-size=150MB
spring.webflux.multipart.max-in-memory-size=${APPSMITH_CODEC_SIZE:150}MB
appsmith.codec.max-in-memory-size=${APPSMITH_CODEC_SIZE:150}

# Log properties
logging.level.root=info
logging.level.com.appsmith=debug
logging.level.com.external.plugins=debug
logging.pattern.console=[%d{ISO8601, UTC}] [%t] requestId=%X{X-Appsmith-Request-Id} userEmail=%X{userEmail} traceId=%X{traceId} spanId=%X{spanId} - %m%n

#Spring security
spring.security.oauth2.client.registration.google.client-id=${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID:missing_value_sentinel}
spring.security.oauth2.client.registration.google.client-secret=${APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET:}
Expand Down
72 changes: 72 additions & 0 deletions app/server/appsmith-server/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<configuration>

<contextName>appsmith-server</contextName>

<property name="SERVICE_INSTANCE_ID" value="${HOSTNAME:-appsmith-0}" />
<property name="DEPLOYMENT_NAME" value="${APPSMITH_DEPLOYMENT_NAME:-self-hosted}" />

<!-- Conditional logging format based on the profile -->
<springProfile name="dev | test">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
[%d{ISO8601, UTC}] [%t] requestId=%X{X-Appsmith-Request-Id} userEmail=%X{userEmail} traceId=%X{traceId} spanId=%X{spanId} - %m%n
</pattern>
</encoder>
</appender>
<!-- Root logger configuration -->
<root level="INFO">
<!-- Refer the appropriate appender based on the profile -->
<appender-ref ref="CONSOLE" />
</root>
</springProfile>

<!-- Console appender with JSON format -->
<springProfile name="production">
<appender name="JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<!-- Add basic information -->
<timestamp>
<fieldName>timestamp</fieldName>
</timestamp>

<contextName/>

<!-- Custom fields for deployment and service instance information -->
<customFields>
{
"deploymentName": "${DEPLOYMENT_NAME}",
"serviceInstanceId": "${SERVICE_INSTANCE_ID}"
}
</customFields>

<!-- Use PatternJsonProvider for structured fields -->
<pattern>
<pattern>
{
"level": "%level",
"logger": "%logger",
"thread": "%thread",
"message": "%message",
"exception": "%exception",
"requestId": "%X{X-Appsmith-Request-Id}",
"userEmail": "%X{userEmail}",
"traceId": "%X{traceId}",
"spanId": "%X{spanId}"
}
</pattern>
</pattern>
</providers>
</encoder>
Comment on lines +27 to +61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider optimizing JSON logging configuration.

The JSON encoder configuration could benefit from stack trace compaction and line separation:

       <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
+        <jsonGeneratorDecorator class="net.logstash.logback.decorate.CompositeJsonGeneratorDecorator">
+          <decorator class="net.logstash.logback.decorate.PrettyPrintingDecorator"/>
+        </jsonGeneratorDecorator>
         <providers>
+          <stackTrace>
+            <throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
+              <maxDepthPerThrowable>30</maxDepthPerThrowable>
+              <maxLength>2048</maxLength>
+              <shortenedClassNameLength>20</shortenedClassNameLength>
+            </throwableConverter>
+          </stackTrace>

This will prevent stack traces from becoming too verbose in production logs.

Committable suggestion skipped: line range outside the PR's diff.

</appender>
<!-- Root logger configuration -->
<root level="INFO">
<appender-ref ref="JSON_CONSOLE" />
</root>
</springProfile>


<logger name="com.appsmith" level="DEBUG" />
<logger name="com.external.plugins" level="DEBUG" />
</configuration>