<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tomasz Szewczyk</title>
    <description>The latest articles on DEV Community by Tomasz Szewczyk (@tomasz_szewczyk_5a7861ced).</description>
    <link>https://dev.to/tomasz_szewczyk_5a7861ced</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3214749%2Fbda6ac3e-3028-47bc-b858-9122c0eaf684.png</url>
      <title>DEV Community: Tomasz Szewczyk</title>
      <link>https://dev.to/tomasz_szewczyk_5a7861ced</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tomasz_szewczyk_5a7861ced"/>
    <language>en</language>
    <item>
      <title>Next.js vs pure React - what we would choose for a landing page, SPA, and e-commerce</title>
      <dc:creator>Tomasz Szewczyk</dc:creator>
      <pubDate>Tue, 03 Feb 2026 19:23:58 +0000</pubDate>
      <link>https://dev.to/tomasz_szewczyk_5a7861ced/nextjs-vs-pure-react-what-we-would-choose-for-a-landing-page-spa-and-e-commerce-47g7</link>
      <guid>https://dev.to/tomasz_szewczyk_5a7861ced/nextjs-vs-pure-react-what-we-would-choose-for-a-landing-page-spa-and-e-commerce-47g7</guid>
      <description>&lt;h2&gt;
  
  
  Working title and summary
&lt;/h2&gt;

&lt;p&gt;Choosing a web technology stack is no longer about what is fashionable. For established businesses, it is about what can be owned, operated, and evolved over many years. Next.js and so called pure React are often discussed as interchangeable, but in practice they solve different problems and introduce different risks. This article compares the two approaches across three concrete project types - a marketing landing page, a business SPA, and an e-commerce system - and explains why the right choice is not the same in each case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Target reader and business context
&lt;/h2&gt;

&lt;p&gt;This comparison is written for owners, directors, and technical decision makers in established small to medium businesses. These organisations usually operate existing systems, have compliance and security obligations, and care about predictable costs. Technology decisions are expected to survive staff changes, integrate with legacy infrastructure, and remain maintainable without constant rewrites. In markets like Poland, where many companies work with external partners such as a &lt;a href="https://bluesbrackets.com/services/node_js_development_companies" rel="noopener noreferrer"&gt;software house poland&lt;/a&gt;, long term ownership and clarity of responsibility matter more than early adoption of new patterns.&lt;/p&gt;

&lt;h2&gt;
  
  
  What "pure React" actually means today
&lt;/h2&gt;

&lt;p&gt;The term pure React is often misunderstood. React is not a complete application framework. It is a user interface library responsible for rendering components and managing state. In production systems, React is always part of a broader setup that includes a build tool, routing, data access, and a deployment model.&lt;/p&gt;

&lt;p&gt;In modern projects, pure React usually means React combined with a fast bundler such as Vite, a client side router, and explicit API communication with backend services. The result is most often a single page application that runs in the browser after loading an initial HTML shell. Hosting is straightforward, because the output consists of static files that can be served by almost any web server or CDN.&lt;/p&gt;

&lt;p&gt;Pure React is also commonly embedded into existing systems. Many established businesses already have backends written in Java, .NET, or PHP. In those cases, React acts only as the frontend layer, while authentication, business logic, and data persistence remain in existing services. This separation aligns well with long term ownership and reduces architectural coupling.&lt;/p&gt;

&lt;p&gt;There are also hybrid approaches. React can be used inside meta frameworks such as Astro, where most content is rendered as static HTML and React is reserved for interactive parts. Newer runtimes like Deno or Bun can host React tooling, but for most businesses they remain alternatives rather than defaults. The key point is that pure React is not a product, but a set of deliberate architectural choices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison framework
&lt;/h2&gt;

&lt;p&gt;Rather than comparing feature lists, this article focuses on operational questions. How is content rendered and delivered. How does this affect search engines. What infrastructure must be run and monitored. How difficult is it to upgrade the system after several years. And what risks are introduced if requirements change.&lt;/p&gt;

&lt;p&gt;These factors matter more to established businesses than marginal performance gains or developer convenience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Landing page case
&lt;/h2&gt;

&lt;p&gt;A typical landing page focuses on content, brand presentation, and lead generation. SEO and fast initial load times are critical. Content changes occasionally, but not per user.&lt;/p&gt;

&lt;p&gt;Next.js fits this model well. It supports static generation, meaning pages are rendered ahead of time into HTML. This results in predictable SEO behaviour and fast delivery. Operationally, a statically generated Next.js site can be deployed as static files, avoiding the need for a permanent server process. Routing and metadata handling are structured and easy to maintain as the site grows.&lt;/p&gt;

&lt;p&gt;A pure React approach is less suitable. A client rendered React application initially serves little or no content and relies on JavaScript execution to display it. While search engines can execute JavaScript, indexing becomes slower and less reliable. Workarounds such as prerendering exist, but they reintroduce complexity that frameworks like Next.js already solve.&lt;/p&gt;

&lt;p&gt;Conclusion for landing pages: if React is required, Next.js is usually the safer choice. In many cases, an even simpler static solution without React may be sufficient, but between these two options, Next.js better supports SEO driven business goals.&lt;/p&gt;

&lt;h2&gt;
  
  
  SPA case
&lt;/h2&gt;

&lt;p&gt;Business SPAs include internal tools, dashboards, and customer portals. They are often behind authentication and not intended for search indexing. The primary concerns are maintainability, integration with backend systems, and predictable operation.&lt;/p&gt;

&lt;p&gt;In this scenario, pure React is usually the better fit. A React SPA communicates directly with existing APIs, keeps rendering on the client, and avoids server side rendering complexity. Hosting remains simple and infrastructure requirements are minimal. Teams retain control over data flow and state management without adapting to framework specific conventions.&lt;/p&gt;

&lt;p&gt;Next.js can be used for SPAs, but many of its features add little value here. Server side rendering is rarely needed for authenticated views. Introducing a server runtime increases operational overhead and the potential failure surface without improving outcomes. Long term maintenance also becomes harder, as teams must track framework changes that do not directly benefit the application.&lt;/p&gt;

&lt;p&gt;Conclusion for SPAs: for most internal or application style systems, pure React offers lower complexity and lower long term risk.&lt;/p&gt;

&lt;h2&gt;
  
  
  E-commerce case
&lt;/h2&gt;

&lt;p&gt;E-commerce systems combine public content with highly dynamic user interactions. Product pages must rank well in search engines, and performance directly affects conversion rates. Integrations with payments, logistics, and external services are common.&lt;/p&gt;

&lt;p&gt;Next.js offers clear advantages in this context. Server side rendering or static generation ensures product pages are crawlable and fast. Hybrid rendering allows public pages to be optimised for SEO while interactive elements such as carts remain client driven. The framework scales well for large numbers of routes and content heavy structures.&lt;/p&gt;

&lt;p&gt;A pure React e-commerce frontend faces structural challenges. Client rendered product pages depend on search engines executing JavaScript, which is slower and less reliable. Prerendering pipelines can reduce the gap, but they often grow into bespoke systems that are expensive to maintain. Over time, the effort required to match the SEO and performance characteristics of server rendered pages usually exceeds the cost of adopting a framework.&lt;/p&gt;

&lt;p&gt;Conclusion for e-commerce: Next.js is typically the more appropriate choice, provided the organisation is prepared to operate and maintain a server side environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Next.js is viable
&lt;/h2&gt;

&lt;p&gt;Next.js is a good architectural choice when SEO is a primary concern, when public content must be delivered quickly, and when a unified approach to rendering and routing reduces long term maintenance risk.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to avoid Next.js
&lt;/h2&gt;

&lt;p&gt;Next.js should be avoided when server side rendering brings little value. This includes internal tools, highly interactive applications, and systems that already rely on established backend architectures. In these cases, the framework increases complexity and cost without improving business outcomes.&lt;/p&gt;

&lt;h2&gt;
  
  
  SEO considerations
&lt;/h2&gt;

&lt;p&gt;Next.js is often described as better for SEO, but the advantage comes from deterministic HTML output at build or request time, not from the framework itself. Search engines and social platforms consume this output more reliably than content rendered only after JavaScript execution. For non public applications, this advantage is irrelevant and should not influence the decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary and decision heuristic
&lt;/h2&gt;

&lt;p&gt;The choice between Next.js and pure React depends on what must be rendered, who consumes it, and how long the system must be supported. If public content and discoverability drive value, Next.js usually justifies its complexity. If the system is primarily an application rather than a publication, pure React keeps ownership costs lower.&lt;/p&gt;

&lt;p&gt;A practical rule is to ask whether the project benefits from server rendered HTML. If the answer is yes, consider Next.js. If not, pure React is often the more durable option.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources and further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://react.dev" rel="noopener noreferrer"&gt;https://react.dev&lt;/a&gt; - explains the scope of React as a UI library
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://vitejs.dev" rel="noopener noreferrer"&gt;https://vitejs.dev&lt;/a&gt; - documents a modern build tool commonly used with React
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://astro.build" rel="noopener noreferrer"&gt;https://astro.build&lt;/a&gt; - shows a static first approach that can still use React components
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://deno.com" rel="noopener noreferrer"&gt;https://deno.com&lt;/a&gt; - illustrates alternative JavaScript runtimes beyond Node
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bun.sh" rel="noopener noreferrer"&gt;https://bun.sh&lt;/a&gt; - presents an emerging runtime and bundler that may influence future tooling choices
&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>react</category>
      <category>node</category>
      <category>nextjs</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Leveraging Stack Traces for SQL Performance Analysis in Spring Boot Applications</title>
      <dc:creator>Tomasz Szewczyk</dc:creator>
      <pubDate>Wed, 30 Jul 2025 20:55:08 +0000</pubDate>
      <link>https://dev.to/tomasz_szewczyk_5a7861ced/leveraging-stack-traces-for-sql-performance-analysis-in-spring-boot-applications-3fae</link>
      <guid>https://dev.to/tomasz_szewczyk_5a7861ced/leveraging-stack-traces-for-sql-performance-analysis-in-spring-boot-applications-3fae</guid>
      <description>&lt;p&gt;Performance optimization in &lt;a href="https://spring.io/projects/spring-boot" rel="noopener noreferrer"&gt;Spring Boot&lt;/a&gt; applications often requires deep visibility into database interactions. While traditional logging provides basic &lt;a href="https://wikipedia.org/wiki/SQL" rel="noopener noreferrer"&gt;SQL&lt;/a&gt; query information, it frequently lacks the crucial context of &lt;em&gt;where&lt;/em&gt; these queries originate in your codebase. This is especially important with lazy loading of &lt;a href="https://hibernate.org/" rel="noopener noreferrer"&gt;Hibernate&lt;/a&gt; entities, where queries can be triggered unexpectedly throughout the application lifecycle. This article demonstrates how to implement a sophisticated logging solution that captures SQL execution stack traces, enabling developers to quickly identify and resolve performance bottlenecks.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Challenge: Contextual SQL Performance Monitoring
&lt;/h2&gt;

&lt;p&gt;In complex Spring Boot applications, SQL queries can be triggered from various layers—controllers, services, repositories, or even background processes. When performance issues arise, developers often face the challenge of connecting slow queries back to their source code. Standard Hibernate logging shows &lt;em&gt;what&lt;/em&gt; queries are executed but not &lt;em&gt;where&lt;/em&gt; they're called from, making optimization efforts time-consuming and error-prone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution Architecture: Custom SQL Logging with Stack Traces
&lt;/h2&gt;

&lt;p&gt;The solution involves creating a custom &lt;a href="https://logback.qos.ch/" rel="noopener noreferrer"&gt;Logback&lt;/a&gt; layout that captures and filters stack traces for SQL operations, providing immediate visibility into the execution path. This approach combines Spring Boot's conditional configuration with Logback's extensible logging framework.&lt;/p&gt;

&lt;p&gt;All code examples in this article are written in &lt;a href="https://kotlinlang.org/" rel="noopener noreferrer"&gt;Kotlin&lt;/a&gt;, leveraging its concise syntax, null safety, and seamless &lt;a href="https://www.java.com" rel="noopener noreferrer"&gt;Java&lt;/a&gt; interoperability. Kotlin's expressive language features make the implementation more readable and maintainable compared to traditional &lt;a href="https://bluesbrackets.com/en/services/hire_java_developers" rel="noopener noreferrer"&gt;Java&lt;/a&gt; approaches, while providing full compatibility with the Spring Boot ecosystem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conditional Configuration Setup
&lt;/h3&gt;

&lt;p&gt;The foundation begins with a configuration class that activates only when needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="nd"&gt;@ConditionalOnProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"sql-logging.stack-trace.enabled"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;havingValue&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;matchIfMissing&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LogConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nd"&gt;@Value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"\${sql-logging.stack-trace.enabled:false}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@PostConstruct&lt;/span&gt;
    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;setMDC&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;MDC&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"springProfile"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;activeProfiles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ifBlank&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;"default"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="nf"&gt;configureSqlLogging&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration uses Spring Boot's &lt;code&gt;@ConditionalOnProperty&lt;/code&gt; annotation to ensure the enhanced logging is only active when explicitly enabled via the &lt;code&gt;sql-logging.stack-trace.enabled=true&lt;/code&gt; property. This design prevents performance overhead in production environments where detailed SQL tracing isn't needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dynamic Logger Configuration
&lt;/h3&gt;

&lt;p&gt;The core logging setup programmatically configures Hibernate's SQL loggers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;configureSqlLogging&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;loggerContext&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LoggerFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getILoggerFactory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;LoggerContext&lt;/span&gt;

    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;appender&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ConsoleAppender&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;qos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;logback&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;classic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;spi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ILoggingEvent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
    &lt;span class="n"&gt;appender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loggerContext&lt;/span&gt;
    &lt;span class="n"&gt;appender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"SQL_STACK_TRACE_APPENDER"&lt;/span&gt;

    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;layout&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SqlLogLayout&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loggerContext&lt;/span&gt;
    &lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;appender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setLayout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;appender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;// Configure SQL query logging&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;sqlLogger&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loggerContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"org.hibernate.SQL"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;Logger&lt;/span&gt;
    &lt;span class="n"&gt;sqlLogger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logback&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;classic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DEBUG&lt;/span&gt;
    &lt;span class="n"&gt;sqlLogger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isAdditive&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;
    &lt;span class="n"&gt;sqlLogger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addAppender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appender&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;// Configure parameter binding logging&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;bindLogger&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loggerContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"org.hibernate.type.descriptor.sql.BasicBinder"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;Logger&lt;/span&gt;
    &lt;span class="n"&gt;bindLogger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logback&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;classic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TRACE&lt;/span&gt;
    &lt;span class="n"&gt;bindLogger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isAdditive&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;
    &lt;span class="n"&gt;bindLogger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addAppender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appender&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration creates dedicated appenders for both SQL queries and parameter binding, ensuring complete visibility into database operations while maintaining separation from other application logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Custom Stack Trace Layout Implementation
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;SqlLogLayout&lt;/code&gt; class provides intelligent stack trace filtering and formatting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SqlLogLayout&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;LayoutBase&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ILoggingEvent&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;ignoredPackages&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;setOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"ch.qos.logback"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;"org.slf4j"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;"java.lang.Thread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;"com.bluesbrackets.config.SqlLogLayout"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;doLayout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ILoggingEvent&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;buildString&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;timestamp&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dateFormatter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Instant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ofEpochMilli&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timeStamp&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="nf"&gt;appendLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"$timestamp [${event.threadName}] ${event.level} ${event.loggerName} - ${event.formattedMessage}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="nf"&gt;appendLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"=== SQL EXECUTION STACK TRACE ==="&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;stackFrames&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;currentThread&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;stackTrace&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asSequence&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ignoredPackages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;none&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;lastWasEllipsis&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;

        &lt;span class="n"&gt;stackFrames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"com.bluesbrackets"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;location&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="o"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lineNumber&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="s"&gt;"$it:${frame.lineNumber}"&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="s"&gt;"Unknown Source"&lt;/span&gt;

                &lt;span class="nf"&gt;appendLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"    at ${frame.className}.${frame.methodName}($location)"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;lastWasEllipsis&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;lastWasEllipsis&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nf"&gt;appendLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"    ..."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;lastWasEllipsis&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nf"&gt;appendLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"=== END STACK TRACE ==="&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Features of the Stack Trace Layout
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Intelligent Filtering&lt;/strong&gt;: Excludes framework and logging infrastructure classes to focus on application code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compact Representation&lt;/strong&gt;: Groups non-application frames into ellipsis markers to reduce noise&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Precise Location Information&lt;/strong&gt;: Includes file names and line numbers for accurate source mapping&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance Conscious&lt;/strong&gt;: Limits stack depth to 500 frames to prevent excessive memory usage&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Benefits and Use Cases
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Immediate Performance Bottleneck Identification
&lt;/h3&gt;

&lt;p&gt;With this logging configuration, developers can immediately identify the source of problematic queries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2024-01-15 14:23:45.123 [http-nio-8080-exec-1] DEBUG org.hibernate.SQL - select user0_.id, user0_.email from users user0_ where user0_.status=?
=== SQL EXECUTION STACK TRACE ===
    at com.bluesbrackets.service.UserService.findActiveUsers(UserService.kt:45)
    at com.bluesbrackets.controller.UserController.getActiveUsers(UserController.kt:28)
    ...
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1087)
    ...
=== END STACK TRACE ===
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This output immediately reveals that the query originates from &lt;code&gt;UserService.findActiveUsers()&lt;/code&gt; called by &lt;code&gt;UserController.getActiveUsers()&lt;/code&gt;, enabling rapid identification and optimization.&lt;/p&gt;

&lt;h3&gt;
  
  
  N+1 Query Detection
&lt;/h3&gt;

&lt;p&gt;The stack trace logging excels at detecting N+1 query patterns by showing repeated calls from the same location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Multiple similar stack traces pointing to the same method
// indicate potential N+1 query issues
at com.bluesbrackets.service.OrderService.loadOrderItems(OrderService.kt:67)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Optimization Impact Measurement
&lt;/h3&gt;

&lt;p&gt;By comparing logs before and after optimizations, developers can quantitatively measure the impact of their changes, ensuring modifications actually improve performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration and Deployment
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Development Environment Setup
&lt;/h3&gt;

&lt;p&gt;Add the following property to your &lt;code&gt;application-dev.properties&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="py"&gt;logging.sql.stack-trace.enabled&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Production Considerations
&lt;/h3&gt;

&lt;p&gt;In production environments, disable the enhanced logging to avoid performance overhead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="py"&gt;logging.sql.stack-trace.enabled&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, use &lt;a href="https://docs.spring.io/spring-boot/reference/features/profiles.html" rel="noopener noreferrer"&gt;Spring profiles&lt;/a&gt; to automatically configure appropriate logging levels:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;spring&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;activate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;on-profile&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;development&lt;/span&gt;
  &lt;span class="na"&gt;logging&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;sql&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;stack-trace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
        &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Performance Considerations
&lt;/h2&gt;

&lt;p&gt;While this logging approach provides invaluable debugging information, consider these performance implications:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stack Trace Capture Overhead&lt;/strong&gt;: Capturing stack traces for every SQL query introduces CPU overhead&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Usage&lt;/strong&gt;: Extended stack traces consume additional memory&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I/O Impact&lt;/strong&gt;: Increased logging volume affects disk I/O performance&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Therefore, this configuration should be used judiciously—enabled during development and debugging phases, but disabled in production unless specific performance issues require investigation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced Usage Patterns
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Custom Filtering Logic
&lt;/h3&gt;

&lt;p&gt;Extend the &lt;code&gt;SqlLogLayout&lt;/code&gt; to implement application-specific filtering:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;criticalPackages&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;setOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"com.yourcompany.service"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"com.yourcompany.repository"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Filter to show only critical application layers&lt;/span&gt;
&lt;span class="n"&gt;stackFrames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; 
    &lt;span class="n"&gt;criticalPackages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;any&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Performance Threshold Logging
&lt;/h3&gt;

&lt;p&gt;Combine this approach with execution time measurement to log stack traces only for slow queries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;executionTime&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;threshold&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Log with stack trace&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Implementing custom SQL logging with stack traces transforms performance debugging from a reactive, time-intensive process into a proactive, efficient workflow. By providing immediate context for database operations, developers can quickly identify bottlenecks, optimize queries, and maintain application performance standards.&lt;/p&gt;

&lt;p&gt;The conditional configuration ensures this powerful debugging tool doesn't impact production performance while remaining readily available for development and troubleshooting scenarios. This approach represents a significant advancement in observability for Spring Boot applications, enabling more efficient development cycles and higher-quality software delivery.&lt;/p&gt;

&lt;p&gt;The combination of Spring Boot's conditional configuration, Logback's extensibility, and intelligent stack trace filtering creates a robust foundation for database performance monitoring that scales with application complexity while maintaining operational efficiency. &lt;/p&gt;

</description>
      <category>programming</category>
      <category>springboot</category>
      <category>sql</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
