Environment Configuration & Logging
Relevant source files
The following files were used as context for generating this wiki page:
- src/main/resources/application.yml
- src/main/resources/logback-spring.xml
- src/main/java/org/example/coding_convention/config/SwaggerConfig.java
- src/main/resources/data.sql
- src/main/java/org/example/coding_convention/file/service/S3UploadService.java
- src/main/java/org/example/coding_convention/websocket/WebSocketController.java
Introduction
The PhanesEditor backend utilizes a Spring Boot-based configuration system to manage environment-specific variables, external service integrations, and comprehensive system logging. The configuration is primarily driven by YAML-based properties, providing a centralized location for database connections, security providers, and cloud infrastructure settings.
The system incorporates a robust logging architecture that supports both console output for real-time debugging and persistent file logging for historical analysis. This ensures high observability across the application's RESTful APIs and WebSocket-based collaborative features.
Core Environment Configuration
The application environment is defined through application.yml, which manages profiles for external integrations including Kakao OAuth2, Gmail SMTP, and Amazon S3.
Infrastructure & External Services
The system relies on several external components configured via environment variables to maintain security and portability.
| Category | Component | Configuration Detail |
|---|---|---|
| Database | MariaDB | Uses MariaDBDialect and a driver-based connection via ${DB_URL}. |
| Cloud Storage | AWS S3 | Configured for ap-northeast-2 region using ${S3_BUCKET}. |
| Security | OAuth2 (Kakao) | Handles authentication via ${AUTH_ID} and ${AUTH_SECRET}. |
| Messaging | Java Mail | Uses Gmail SMTP on port 587 with STARTTLS enabled. |
Sources: src/main/resources/application.yml:1-68
Database Initialization
The system is configured to perform SQL initialization automatically. The data.sql file defines the schema for users, projects, files, and chats, while the application configuration ensures that the datasource initialization is deferred to allow JPA and Hibernate to synchronize correctly.
Logging Architecture
The logging system is configured via logback-spring.xml, providing a dual-destination strategy (Console and File) with specific color-coding and rolling policies.
Log Output Channels
- CONSOLE: Utilizes
ColorConverterto provide colored output for different log levels (e.g., magenta for dates, blue for levels, green for loggers, and yellow for messages). - FILE: Implements a
RollingFileAppenderlocated in thelogs/directory. It uses aTimeBasedRollingPolicyto archive logs daily and retains them for a maximum of 30 days.
Logger Levels and Persistence
The application differentiates log levels for specific frameworks to aid in debugging database transactions.
| Logger | Level | Purpose |
|---|---|---|
| Root | INFO | Default level for application code. |
| org.hibernate.SQL | DEBUG | Displays generated SQL queries. |
| org.hibernate.orm.jdbc.bind | TRACE | Displays parameter values bound to SQL queries. |
Sources: src/main/resources/logback-spring.xml:22-26, src/main/resources/application.yml:71-75
API and Security Configuration
The backend exposes its configuration and capabilities through automated documentation and secure communication protocols.
Swagger/OpenAPI Documentation
The system uses SwaggerConfig to define API metadata. It is configured to support Bearer Token authentication (JWT), ensuring that protected endpoints are visible but require proper authorization.
- Title: Phanes API (v1)
- Security Scheme: HTTP Bearer (JWT)
Sources: src/main/java/org/example/coding_convention/config/SwaggerConfig.java:14-25
WebSocket Logging
The WebSocketController is annotated with @Slf4j, enabling logging for real-time communication events. This is used to track messages sent to chat rooms and editor rooms, which are routed via the SimpMessagingTemplate.
Summary
The environment configuration and logging systems in PhanesEditor-BE are designed for scalability and maintainability. By externalizing sensitive credentials into environment variables and implementing a structured logging policy via Logback, the project ensures a secure development-to-production pipeline with high visibility into system behavior.