Skip to content

"gui-log" RollingFile Appender

This appender manages graphical interface logs with automatic file rotation.

Configuration example:

xml
<Appenders>
    <RollingFile name="gui-log" fileName="logs/gui.log" filePattern="logs/gui-%d{yyyy-MM-dd}.log">
        <PatternLayout pattern="%d %-5p [%t][%c][%X{MDC_SESSION}] - %m%n"/>
        <Policies>
            <SizeBasedTriggeringPolicy size="256MB"/>
        </Policies>
        <DefaultRolloverStrategy max="10"/>
    </RollingFile>
</Appenders>

Example Log :

text
2025-02-05 17:24:11,914 INFO  [qtp1830190936-44][com.okiok.sfiler.java.gui.web.action.Logout][8ac0740e-9bd7-4f8a-b90c-f864fe583508] - Terminating session for user : my-user

Log details:

  1. 2025-02-05 17:24:11,914 : Date and time of the log
  2. INFO : Log level
  3. [qtp1830190936-44] : Thread name
  4. [com.okiok.sfiler.java.gui.web.action.Logout] : Class name generating the log
  5. [8ac0740e-9bd7-4f8a-b90c-f864fe583508] : User session identifier (from MDC)
  6. - Terminating session for user : my-user : Log message

Basic Configuration

  • Name: gui-log
  • Output file: logs/gui.log
  • Archive file pattern: logs/gui-[DATE].log

Log Format

The pattern %d %-5p [%t][%c][%X{MDC_SESSION}] - %m%n defines the following format:

  • %d : Log date and time
  • %-5p : Log level (DEBUG, INFO, ERROR...) aligned to 5 characters
  • [%t] : Thread name
  • [%c] : Class name generating the log
  • [%X{MDC_SESSION}] : User session identifier (from MDC)
  • %m : Log message
  • %n : Line break

Rotation Policy

  • SizeBasedTriggeringPolicy: 256MB per file
  • DefaultRolloverStrategy: Maximum 10 archive files
  • Rotation creates a new file when:
    • Current file reaches 256MB
    • A new day begins (based on date pattern)

Characteristics

  • Format particularly suitable for:
    • Tracking user actions in the interface
    • Diagnosing user interface issues
    • Analyzing user sessions
    • Tracing client interactions

References